开发者

If form value equals a specifc then die

开发者 https://www.devze.com 2023-02-07 18:52 出处:网络
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 qu

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!");
}
0

精彩评论

暂无评论...
验证码 换一张
取 消