Learn how to create a sign-up form for a website with a security image. The image prevents fake sign-ups and spam. In this tutorial, we will learn how to create a security image template, then put it to use.
//Destroy the image to free memory imagedestroy($im);
//Insert reference into database, and delete any old ones mysql_connect("localhost", "username", "password") or die(mysql_error()); mysql_select_db("dw_php"); //Create reference mysql_query("INSERT INTO security_images (insertdate, referenceid, hiddentext) VALUES ( now(), '".$referenceid."', '".$textstr."')"); //Delete references older than 1 day mysql_query("DELETE FROM security_images WHERE insertdate < date_sub(now(), interval 1 day)");
//End Output exit;
?>
Open securityimage.php in a browser. You should see something like the image below:
Now, we are finished with the file and ready to put it to use!
Note: If you receive a message about ImageCreateFromPNG being an undefined function, this is probably because you don't have the GD Graphics Library installed. Install this (download may be obtained from http://www.boutell.com/gd/) and retry.