Php 自定义WP表格不支持';不要存储任何数据

Php 自定义WP表格不支持';不要存储任何数据,php,javascript,wordpress,customization,Php,Javascript,Wordpress,Customization,我有一个自定义word press表单,但当我填写表单并单击“提交”时,只会得到一个空白页 我期望的是我的数据存储在数据库中的表中,然后转发到下一页 这是我的html代码+表单验证代码(WP端): 名称 电话 传真 网址 陈述 地址 // 这是用于数据存储功能的php: <?php //establish connection $con = mysqli_connect("localhost","XXX","XXX","android_app"); //on connection

我有一个自定义word press表单,但当我填写表单并单击“提交”时,只会得到一个空白页 我期望的是我的数据存储在数据库中的表中,然后转发到下一页

这是我的html代码+表单验证代码(WP端):


名称
电话
传真
网址
陈述
地址
// 
这是用于数据存储功能的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"); 
?>


Wordpress似乎不喜欢输入字段名,如“name”“year”和其他一些

请尝试重命名这些字段名称,使其更具体。

因此,现在可以通过以下方法解决此问题:

  • 使用action=“localhost/wordpress/process.php”;而不是现在的

  • 对于:$name=$\u POST[“name”]$电话=$_POST[“电话”]$传真=$_POST[“传真”]; $webaddress=$_POST[“webaddress”]$state=$_POST[“state”]$地址=$邮政[“地址”]

  • 所有大写字母均改为小写,并将“”替换为“”


    我猜就这些了,谢谢大家

    我相信索引是区分大小写的。尝试将
    $name=$\u POST[“name”]
    更改为
    $name=$\u POST[“name”]
    。注意第一个字母的变化,以及使用单引号而不是双引号。另外,可能没有必要为每段代码都设置一个打开和关闭php块。@cwscribner我按照您的建议进行了修改,除了php块的打开和关闭,但仍然没有任何更改!!!您好,表单的action属性是“C:\xampp\htdocs\wordpress\process.php”,您确定可以这样做吗?您是否可以尝试将其更改为“htt p://localhost/wordpress/process.php”?验证表单的函数不应包含在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"); 
    ?>