Before my data is entered into the database using the $_POST
function I would like to check the name of a field. If the 开发者_如何学Ccomment_author_name is equal to a specific name, I would like to quit/die/kill the function.
For example, if the name of the comment author is John on the HTML form, I would like the PHP function to die so that the data does not get entered into the database.
The below code isn't working. What am I missing? Is there a better way to do this??
<?php
$val1 = "John";
if (($row->comment_author_name) == ($val1))
{
die("You are not allowed to post!");
}
?>
You can do:
if ($_POST['comment_author_name'] == 'John'){
die("You are not allowed to post!");
}
精彩评论