View Single Post
  #3 (permalink)  
Old 08-20-2008, 12:14 PM
Tech Manager Tech Manager is offline
WebProWorld Pro
 
Join Date: Jan 2008
Posts: 290
Tech Manager RepRank 1
Default Re: Need a secure contact form script (php5)

Quote:
Originally Posted by Web-Design-Guy View Post
Can anyone help me out?

Ideally, rather than CAPTCHA, it will ask maths questions or similar.

Here's hoping.
Here's a simple script that will produce your math questions:

Make sure you have sessions enabled.

Code:
srand ((double) microtime( )*1000000);
$_SESSION['human_check'] = rand(0,999);
$question = ($_SESSION['human_check'] - 1);
$question2 =  "What is the next number after the number " . $question . "?";

Add the question to your form:

Code:
 
<label /><?php echo $question2; ?> <input type="text" name="human_answer" size="3" maxlength="3" value="0" />
Compare the response with your $_SESSION['human_check'] variable.
Code:
 
if($_SESSION['human_check'] == $_POST['human_answer']) {
   $g = TRUE;
 } else {
   $g = FALSE;
   $message[] = "You failed to enter the correct number into the number field.";
   }
Validate the rest of your variables and you're set.
__________________
I use Country IP Blocks as added security for my networks and servers.

Last edited by Tech Manager; 08-20-2008 at 12:17 PM.
Reply With Quote