conker87 Posted May 30, 2007 Share Posted May 30, 2007 I'm on a server that only allows for SMTP mail() however I cant get it to send mail and I can seem to find anywhere how to set up SMTP mail() in the php script, so I thought sod it and coded my registration script without it. Now I'm wanting some sort of field on the register page that can help identify humans. I'm thinking something along the lines of the having a $var == rand(); and have the registee input 2 numbers that have to equal the rand(); number when added. I'm just wondering what other people use to identify humans and ward off bots. Quote Link to comment https://forums.phpfreaks.com/topic/53583-verifiy-human-without-emailing/ Share on other sites More sharing options...
chigley Posted May 30, 2007 Share Posted May 30, 2007 CAPTCHA. Here's one I made earlier index.php <?php // Begin the session to receive the code used from the image.php file session_start(); ?> <form action="action.php" method="post"> <img src="image.php" alt="Security Image" /><input type="text" id="code" name="code" /> <input type="submit" value="Submit" /> </form> action.php <?php // Start the session to check the codes session_start(); // Check the code if(($_SESSION['code'] == $_POST['code']) && (!empty($_SESSION['code'])) ) { echo "Code correct"; unset($_SESSION['code']); } else { echo "Code incorrect"; } ?> image.php <?php /*-----------------------------------------------------------*\ | **************** User Editable Variables ****************** | +-------------------------------------------------------------+ | $length -> the length of the string displayed on the image | | $chars -> the character range used in the string | | $fontsize -> the size of the font to be used in pixels | | $fontfile -> the TTF font file you want to be used | | $imagewidth -> the image width in pixels | | $imageheight -> the image height in pixels | | $textcolour -> comma separated RGB values of the text colour| | $noisetotal -> the number of noise pixels required | | $noisecolour -> RGB values of the noise colour | \*-----------------------------------------------------------*/ $length = 6; $chars = "ABCDEFGHJKLMNOPQRSTUVWXYZabcdefhkmnorstuvwx123456789"; $fontsize = 14; $fontfile = "mono.ttf"; $imagewidth = 45; $imageheight = 22; $textcolour = "0,0,0"; $noisetotal = 100; $noisecolour = "0,0,255"; /*------------------------------------------------------------*\ | ********************** Captcha Code ************************ | \*------------------------------------------------------------*/ // Start the session, to send the code used to other pages session_start(); // Reset the variables $code = ""; // Split the availiable character range into separate characters $chars = preg_split('//', $chars, -1, PREG_SPLIT_NO_EMPTY); // Choose $length number of random characters from the array $keys = array_rand($chars, $length); // Add each of the chosen characters to the $code array $codearr = array(); foreach($keys as $key => $value) { $value = $chars[$value]; array_push($codearr, $value); $code .= $value; } // Create the image // Begin to make the image using GD header ("Content-type: image/png"); $img = imagecreatetruecolor($imagewidth, $imageheight); // Define the colours $white = imagecolorallocate($img, 255, 255, 255); $colour = explode(",", $textcolour); $colour = imagecolorallocate($img, $colour[0], $colour[1], $colour[2]); $noise = explode(",", $noisecolour); $noise = imagecolorallocate($img, $noise[0], $noise[1], $noise[2]); // Add the data imagefill($img, 0, 0, $white); // Add the noise while($noisecount < $noisetotal) { $randomx = rand(0, imagesx($img)); $randomy = rand(0, imagesy($img)); imagesetpixel($img, $randomx, $randomy, $noise); $noisecount++; } // Calculate the angle to be used $angle = rand(-5, 5); if($angle < 0) { $y = $imageheight - 10; } else { $y = $imageheight; } imagettftext($img, $fontsize, $angle, 0, $y, $colour, $fontfile, $code); // Output the image imagepng($img); imagedestroy($img); // Send the session variable to the next page accessed to check if the code was correct $_SESSION['code'] = $code; ?> Quote Link to comment https://forums.phpfreaks.com/topic/53583-verifiy-human-without-emailing/#findComment-264830 Share on other sites More sharing options...
Dragen Posted May 30, 2007 Share Posted May 30, 2007 Image captcha is probably one of your best bets as chigley has said, but most bots now can decipher captcha very easily, so you need more than just captcha. Quote Link to comment https://forums.phpfreaks.com/topic/53583-verifiy-human-without-emailing/#findComment-264835 Share on other sites More sharing options...
chigley Posted May 30, 2007 Share Posted May 30, 2007 Yeah well it's better than nothing! TicketMaster has a very good CAPTCHA code: Quote Link to comment https://forums.phpfreaks.com/topic/53583-verifiy-human-without-emailing/#findComment-264839 Share on other sites More sharing options...
per1os Posted May 30, 2007 Share Posted May 30, 2007 You can use a question captcha. Where inside the image you write a question like: What is 1 + three? Answer would be 4. That way it is tougher for bots to interpret that especially from an image. Or Two Apples plus One Apple equals? Answer would be 3 apples. Quote Link to comment https://forums.phpfreaks.com/topic/53583-verifiy-human-without-emailing/#findComment-264851 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.