TrueCrypt How to use PHP form submission procedure safe use 1th/2 page

Source: Internet
Author: User
Tags php form
Used to display error messages and success messages, you can actually echo the error message directly, here I just want my error message page beautiful point, defined a page output function.

Copy the Code code as follows:


savecomment.php//people don't look at the comments, after reading this article, and then look back
Require ("config.php");
Mysql_connect ($servername, $dbusername, $dbpassword) or Die ("database connection failed");
$name =$_post[' name '];
$c
$blogid =$_post[' blogID '];
$datearray =getdate (Time ());
$date =date ("y-m-d h:i:s", $datearray [0]);
if (!empty ($name) &&!empty ($content)) {
Use the empty function to determine if the form is not empty, then go down.
if (strlen ($name) > 20) {
The length of the $name is judged by the non-null judgment.
Error ("Name exceeds 20 bytes (20 English or 10 kanji)
”);
}
F (!is_numeric ($_post[' blogID ')) {
Error ("The hidden data has been modified illegally, please return
”);
}
Since $blogid is going to be put in select, this variable is used to indicate which article the comment belongs to, it is of type int, although it is a hidden variable, but the attacker can also modify the remote commit locally, so we need to check the type before putting in the select.
$blogsql = "SELECT * from $comment _table Where blogid= $blogid"
$blogresult = Mysql_db_query ($dbname, $blogsql);
$blog = Mysql_fetch_array ($blogresult);
if (strlen ($name) = = strlen ($blog [name]) && strlen ($content) = = strlen ($blog [content]) {
Query the length of the database of two fields, because the name length may be the same, but two are the same normal occurrence of the probability is quite small, so use && at the same time to judge.
Error ("You want to submit a comment that already exists in the content, please return
”);
}
Start judging the time interval below. See later in this article for more detailed instructions.
Session_Start ();
if ("session_is_registered (") && time ()-$_session[']<60*2) {error ("Sorry, you have two commits in less than 2 minutes
”);
} else {
$sql = "Insert into $comment _table (date,name,content,blogid) VALUES (' $date ', ' $name ', ' $content ', ' $blogid ')"
Mysql_db_query ($dbname, $sql);
Mysql_close ();
$time =time ();
Session_register ("Time");
Succeed ("Comment submitted successfully
”);
}}
End a non-empty judgment
Error ("You did not fill out all of the forms
”);
?>


Above is a file that records comment data. The form is as follows:

Copy the Code code as follows:




Current 1/2 Page 12 next page

The above describes the use of TrueCrypt PHP form submission Program safe use 1th/2 pages, including the use of TrueCrypt content, I hope to be interested in PHP tutorial friends helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.