我有一个自定义单词印刷表格,但当我填写并点击提交时,我只是得到一个空白页面 我期待的是我的数据存储在我的数据库表中,然后转发到下一页
这是我的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");
?>
我希望有人可以提供一些帮助
谢谢
答案 0 :(得分:0)
Wordpress似乎不喜欢“name”,“year”等输入字段名称。
尝试重命名这些字段名称,使其更具体。
答案 1 :(得分:0)
所以它现在通过以下方式解决:
使用action =“localhost / wordpress / process.php”;而不是当前的
for:$ name = $ _ POST [“Name”]; $电话= $ _ POST [ “电话”]; $传真= $ _ POST [ “传真”]; $ webaddress = $ _ POST [ “Webaddress”]; $状态= $ _ POST [ “国家”]; $地址= $ _ POST [ “地址”];
所有大写字母都变为小写,而“”被替换为''
这就是我想所有人的感谢