admin管理员组文章数量:1130349
Question asked million times and answered, but still not working for me for the simplest form. My code looks like this right now:
<?php
if (!empty($_POST)) {
global $wpdb;
$table = username;
$data = array(
'name' => $_POST['yourname'],
'chord' => $_POST['chord']
);
$format = array(
'%s',
'%s'
);
$success=$wpdb->insert( $table, $data, $format );
if($success){
echo 'data has been save' ;
}
} else {
?>
<form method="post">
<input id="user_name" type="text" name="yourname" placeholder="Name">
<input id="user_email" type="text" name="email" placeholder="Email">
<button id="button" type="button" name="submit">Go</button>
</form>
<?php
}
?>
I don't know what $_POST does and how does it submit data to database if there is no event handler on the form? I'm not getting any errors either, it just doesn't store anything.
Question asked million times and answered, but still not working for me for the simplest form. My code looks like this right now:
<?php
if (!empty($_POST)) {
global $wpdb;
$table = username;
$data = array(
'name' => $_POST['yourname'],
'chord' => $_POST['chord']
);
$format = array(
'%s',
'%s'
);
$success=$wpdb->insert( $table, $data, $format );
if($success){
echo 'data has been save' ;
}
} else {
?>
<form method="post">
<input id="user_name" type="text" name="yourname" placeholder="Name">
<input id="user_email" type="text" name="email" placeholder="Email">
<button id="button" type="button" name="submit">Go</button>
</form>
<?php
}
?>
I don't know what $_POST does and how does it submit data to database if there is no event handler on the form? I'm not getting any errors either, it just doesn't store anything.
本文标签: phpHow to grab data from input and store it into custom table in database
版权声明:本文标题:php - How to grab data from input and store it into custom table in database? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749188118a2329732.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论