gpt4 book ai didi

php - Wordpress 插件表单提交

转载 作者:搜寻专家 更新时间:2023-10-31 21:41:26 26 4
gpt4 key购买 nike

我创建了一个插件来保存回复我的详细信息。但是每当我使用插件提交表单时,它都会显示错误,并且会被重定向到其他显示“未找到”的页面抱歉,找不到您请求的页面。也许搜索会有所帮助。”消息。请检查我的代码

<?PHP
/*
Plugin Name: Register Me
Plugin URI: http://demo.net
Description: Plugin is shows a simple Registration form
Author: Sumod Nair
Version: 1.0
Author URI: http://demo.net
*/
add_action('init', 'reg_install');
function reg_install()
{
global $wpdb;
$table = $wpdb->prefix."reg_details";
$structure = "CREATE TABLE $table (
id INT(9) NOT NULL AUTO_INCREMENT,
name VARCHAR(80) NOT NULL,
place VARCHAR(20) NOT NULL,
email VARCHAR(20) NOT NULL,
mobno VARCHAR(20) NOT NULL,
about_me VARCHAR(500) NOT NULL,
date_apply datetime,
UNIQUE KEY id (id)
);";
$wpdb->query($structure);
}

add_shortcode('register', 'process_post');

function process_post(){
//include("reg_form.php");
?>
<form id="frmRegistration" name="frmRegistration" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>" method="POST">
<table style="align:center; width:500px; margin: 0 0 0 0;">
<tr>
<td>Name </td>
<td><input type="text" name="name" id="name" maxlength="50" ><b><font color="red">*</font></b></td>
</tr>
<tr>
<td>Place </td>
<td><input type="text" name="place" id="place" maxlength="50" ><b><font color="red">*</font></b></td>
</tr>
<tr>
<td>Email </td>
<td><input type="text" name="email" id="email" maxlength="50" ><b><font color="red">*</font></b></td>
</tr>
<tr>
<td>Mobile No</td>
<td><input type="text" name="mobile_no" id="mobile_no" maxlength="50"><b><font color="red">*</font></b></td>
</tr>
<tr>
<td>About Yourself</td>
<td><textarea rows="4" cols="50" name="about" id="about" >

</textarea> <b><font color="red">*</font></b></td>
</tr>
<tr>
<td><input type="submit" name="btnSubmit" id="btnSubmit" value="Submit Details" style="color:blue;"></td>
<td align="right"><b><font color="red">*</font></b> fileds are mandatory</td></tr>
</table>
</form>

<?PHP
global $wpdb;
$table = $wpdb->prefix."reg_details";
if(isset($_POST['btnSubmit'])) {
// process $_POST data here
$name = $_POST['name'];
$place = $_POST['place'];
$email = $_POST['email'];

$mobile_no = $_POST['mobile_no'];
$about_yourself = $_POST['about'];
echo $name." " .$place." " .$email ." " .$mobile_no." " .$about_yourself;
$wpdb->query("INSERT INTO $table(name, place,email,mobno,about_me,date_apply)
VALUES('$name', '$place',' $email', '$mobile_no', '$about_yourself',now())");
}
}
?>

最佳答案

name="name" 替换为其他内容,我遇到了完全相同的“错误”。可以肯定的是,也可以用它前面的一些唯一字符串替换其他名称。例如。 name="frm-name", name="frm-mobile_no"

关于php - Wordpress 插件表单提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10593814/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com