textareaフィールドを介して送信されたデータにctype_alphaを使用したいのですが、データは特殊文字を含まないアルファベットのみである必要があります。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.";
}
}
?>