hershiser55 Posted May 20, 2009 Share Posted May 20, 2009 Hi - sorry, but I'm a complete PHP rookie and am trying to get my image verification routine working again. The PHP block which generates the image is: <?php @session_start(); $new_string; @session_register('new_string'); $im = ImageCreate(60, 40); $white = ImageColorAllocate($im, 255, 255, 255); $black = ImageColorAllocate($im, 0, 0, 0); srand((double)microtime()*1000000); $string = md5(rand(0,9999)); $new_string = substr($string, 17, 5); ImageFill($im, 0, 0, $black); ImageString($im, 4, 10, 14, $new_string, $white); ImagePNG($im, "verify.png"); ImageDestroy($im); ?> and the PHP that evaluates the entry is: <?php $name = $_REQUEST['name']; $from = $_REQUEST['email']; $category = $_REQUEST['category']; $comment = $_REQUEST['comment']; $message = "Name: " . $name . "\n" . "Email: " . $from . "\n" . "Category: " . $category . "\n" . "Comment: " . $comment; @session_start(); $random = trim($random); if ((stristr($message, 'http://') === FALSE) && ($new_string == $random)) { if (strlen(trim($name)) > 0 && strlen(trim($comment)) > 0) { if ((stristr($comment, 'viagra') === FALSE) && (stristr($comment, 'drugs') === FALSE)) { mail("[email protected]", "Title", $message); header( "Location: http://www.mywebsite.com" ); } else { echo 'Invalid guestbook entry'; } } else { echo 'Name and comment must be entered'; } } else { echo 'Unable to process guestbook entry'; } ?> Why is the value of $new_string not visible when performing the validation? Sometimes it seems to work, but more often than not the value is blank on this form. I'm sure there is something wrong with the session_start or session_register calls. Thanks for any help on this, Todd Link to comment https://forums.phpfreaks.com/topic/158948-variable-visibility-when-performing-image-verification-routine/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.