我有一个自定义的 word press 表单,但是当我填写并单击提交时,我只得到一个空白页,我期望我的数据将存储在数据库中的表中,然后转发到下一页
这是我的html代码+表单验证代码(WP端):
<html>
<body>
<form action="C:\xampp\htdocs\wordpress\process.php" method="post" name="myForm">
Name <input id="name" type="text" name="name" />
Telephone <input id="telephone" type="text" name="telephone" />
Fax <input id="fax" type="text" name="fax" />
Web address <input id="webaddress" type="text" name="webaddress" />
State <input id="state" type="text" name="state" />
Address <input id="address" type="text" name="address" />
<input type="submit" value="Submit" /></form>
<\html>
<\body>
<script type="text/javascript">// <![CDATA[
/* JS validation code here */
function validateForm()
{
/* Validating name field */
var x=document.forms["myForm"]["name"].value;
if (x==null || x=="")
{
alert("Name must be filled out");
return false;
}
/* Validating email field */
var x=document.forms["myForm"]["telephone"].value;
if (x==null || x=="")
{
alert("telephone must be filled out");
return false;
}
}
// ]]></script>
这是数据存储功能的 php:
<?php
//establish connection
$con = mysqli_connect("localhost","XXX","XXX","android_app");
//on connection failure, throw an error
if(!$con) {
die('Could not connect: '.mysql_error());
}
?>
<?php
//get the form elements and store them in variables
$name=$_POST["Name"];
$telephone=$_POST["Telephone"];
$fax=$_POST["Fax"];
$webaddress=$_POST["Webaddress"];
$state=$_POST["State"];
$address=$_POST["Address"];
?>
<?php
$sql="INSERT INTO `android_app`.`islamic_organisation` ( `Name` , `Telephone` , `Fax` , `WebAddress` , `state` , `Address`) VALUES ( '$name','$telephone', '$fax', '$webaddress' , '$state', '$address')";
mysqli_query($con,$sql);
?>
<?php
//Redirects to the specified page
header("Location: http://localhost/wordpress/?page_id=857");
?>
我希望有人可以提供一些帮助
谢谢