繁体   English   中英

ctype_alpha在换行符上返回FALSE

[英]ctype_alpha returns FALSE on line-break

我想将ctype_alpha用于通过textarea字段提交的数据,该数据应完全是字母,没有特殊字符。 虽然在断行返回FALSE时仍如何使用它?

这是HTML代码:

<?php
include_once('../../header.php');
include_once('../../model/contribution/create_new_tag_script.php');
?>

<form action="" method="post">
    <input type="text" name="tag_name" value="" />
    <textarea maxlength="60" type="text"  name="tag_description" value=""></textarea>
    <input type="submit" name="tag_name_submit" value="Submit the New Tag" />
</form>


<?php
include_once('../../footer.php');
?>

这是PHP代码:

<?php
# This script does get included into the document create_new_tag_from.php




    if(isset($_POST['tag_name_submit'])){
    $tag_name_submit = $_POST['tag_name_submit'];
    }

    if(!empty($_POST['tag_name'])){
    $tag_name = strip_tags($_POST['tag_name']);
    }

    if(!empty($_POST['tag_description'])){
    $tag_description = strip_tags($_POST['tag_description']);
    }


if(isset($tag_name_submit)){



    # The Validation of User Entered Data
    # Do validate for solely alphabetic characters with ctype_alpha

    # ctype_alpha($tag_name) && 
    if(ctype_alpha($tag_description)){
        $tag_name = strtolower($tag_name);
        $tag_description = strtolower($tag_description);


    # The Insertion Into the Database
    $db_connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);



    $sql_query = sprintf(

            "set @newid = convert(

              ( select 
               max(convert( (substring(tag_id, 2)) , unsigned integer))+1
               from tags), char(10) );

                set @newid = if(length(@newid) = 1, concat('0', @newid), @newid);
                set @newid = concat('c', @newid);

                INSERT INTO tags (tag_id, tag_name, tag_description, added_by_user_id,
                                creation_date, last_edited)
                VALUES (@newid, '%s', '%s', 7, now(), '0')",

                mysqli_real_escape_string($db_connect, $tag_name),
                mysqli_real_escape_string($db_connect, $tag_description)


            );

    $sql_query_run = mysqli_multi_query($db_connect, $sql_query);

    # Print Test to See If It Works
    echo "works_ ";
    echo $tag_name . "_ ";
    echo $tag_description . "_ ";


        } else { # End of the Validation
            echo "The entered data must be in alphabetic characters.";
        }

}



?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM