Reputation: 5
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
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.
The code simply stop when it comes to $Title. it doesn't even leaves a error on chrome DevTool
Upvotes: 0
Views: 125
Reputation: 5
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]);}
Upvotes: 0
Reputation: 158
As far as I know get_post() is not a standard php function, unless if its wordpress.
Try changing from
$Title = get_post($conn, 'title');
to
$Title = $_POST['title'];
Upvotes: 2