checkcode.php generates a verification code image, as well as the variable $_SESSION[check_pic].
imagestring($im,rand(5,6),rand(25,30),5,$rand,$te); used int imagestring(int im, int font, int x, int y, string s, int col); function, this function is used to draw horizontal strings.
This function draws a horizontal string on the image. The parameter font is the font, and setting it from 1 to 5 means using the default font. The parameters x and y are the starting point coordinates of the string. The contents of the string are placed on parameter s. Parameter col represents the color of the string.
post.php
Compare $_POST[check] and $_SESSION[check_pic]. If they are equal, perform database insertion. If not equal, return to the previous page.
Copy code The code is as follows:
session_start();
if(isset( $_POST[check]))
{
if($_POST[check] == $_SESSION[check_pic])
{
// echo "Verification code is correct".$_SESSION[check_pic] ;
require("dbinfo.php");
$name = $_POST['name'];
$email = $_POST['email'];
$website = $_POST[ 'website'];
$content = $_POST['content'];
$date = date("Y-m-d h:m:s");
// Connect to MySQL server
$ connection = mysql_connect ($host, $username, $password);
if (!$connection)
{
die('Not connected : ' . mysql_error());
}
//Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected)
{
die ('Can't use db : ' . mysql_error ());
}
//Insert data into the database
$query = "insert into table (nowamagic_name, nowamagic_email, nowamagic_website, nowamagic_content, nowamagic_date) values ('$name','$email', '$website','$content','$date')";
$result = mysql_query($query);
if($result)
{
echo "<script> alert('Submission successful'); history.go(-1);</script>";
}
if (!$result)
{
die('Invalid query: ' . mysql_error());
}
}
else
{
echo "
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31