[英]why can't i get the value from post form, with get_post method php
I am trying to get data from a post form, but somehow the code is stopping, so that $Title
doesn't gets a value, and the second alert doesn't kick in 我正在尝试从发布表单中获取数据,但是代码以某种方式停止了,因此
$Title
没有得到值,并且第二个警报也没有启动
if(isset($_POST['title'])) {
echo "<script type='text/javascript'>alert('test');</script>";
$Title = get_post($conn, 'title');
echo "<script type='text/javascript'>alert('$Title');</script>";
}
I expected the $Title
to get the value from the form, and being alerted. 我希望
$Title
从表单中获取值,并得到警告。 The code simply stop when it comes to $Title. 当涉及到$ Title时,代码就停止了。 it doesn't even leaves a error on chrome DevTool
它甚至不会在chrome DevTool上留下错误
As far as I know get_post() is not a standard php function, unless if its wordpress. 据我所知,get_post()不是标准的php函数,除非它是wordpress。
Try changing from 尝试从
$Title = get_post($conn, 'title');
to 至
$Title = $_POST['title'];
The problem was that i copied some code from another project, but forgot to copy this: 问题是我从另一个项目复制了一些代码,但是忘了复制:
function get_post($conn, $var){
return $conn->real_escape_string($_POST[$var]);}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.