Home  >  Article  >  Backend Development  >  How to use truecrypt. How to use the PHP form submission program safely. Page 1/2

How to use truecrypt. How to use the PHP form submission program safely. Page 1/2

WBOY
WBOYOriginal
2016-07-29 08:38:24895browse

It is used to display error messages and success messages. In fact, it can also directly echo error messages. Here I just want my error message page to be more beautiful, so I define a function for page output.

Copy the code The code is as follows:


// savecomment.php// Please don’t read the comments now. After reading this article, come back and look at it
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) ;                                                                                                                                                               
error("The name exceeds 20 bytes (20 English or 10 Chinese characters)
");                                                                                                          I have been modified illegally, please return & lt; br & gt; ");
}
// Since $ blogid will be placed in select later, this variable is used to indicate which article belongs to, it is an INT type, although it is although it is said It is a hidden variable, but an attacker can also modify the remote submission locally, so we need to check the type before putting it 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 two fields of the database, because the name length may be the same, but both are the same. Normally The probability of occurrence is quite small, so use && to judge at the same time. Error ("The content you want to submit exists, please return to & lt; br & gt;");
}
// began to judge the time interval below. For more detailed instructions, please see later in the article. _Session_start ();
IF (Session_is_register ("Time") && Time ()-$ _ session ['time'] & lt; 60*2) {error ("Sorry, the time interval you submit twice is less than 2 minutes. & lt; br & gt; ");
} else {
$ SQL =" Insert Into $ Comment_table (Date, Name, Content, Blogid) Values ​​('$ Date', '$ Name', '$ Content', ' $ blogid ' " br>”);
}}
//End the non-empty judgment
error("You have not filled out all the forms
");
?>


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



Copy the code

The code is as follows:




Your name:
Comment content:


Current 1/2 page 12Next page

The above introduces the use of truecrypt. The safe use of PHP form submission program on page 1/2, including the use of truecrypt. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn