Jump to content

Newbie problems with contact form and CAPTCHA script


fizzy

Recommended Posts

Hi,

 

Im trying to get a form on my webpage to use a captcha script. I found one that seems to work but im struggling to make it use the part of my existing script that sends the email.

 

At the moment it is processing the form data, but not testing the CAPTCHA code. Its driving me insane!

 

Could somebody have a look and see if you can see what I'm doing wrong?

 

form.html

<form action="result.php" METHOD="POST">
    <input name="wawa" type="text">
      <p><img src="imagebuilder.php" border="1">  </p>
      <p>Please enter the code shown above and click Submit.<br>
        <input MAXLENGTH=8 SIZE=8 name="userstring" type="text" value="">
        <br>
        <input type="submit" value="Submit">
      </p>
    </form>
  </div>

 

result.php

<?php

include "settings.php";


$string = strtoupper($_SESSION['string']);
$userstring = strtoupper($_POST['userstring']); 


ini_set("sendmail_from", "***@***.com");

   if ($_SERVER['REQUEST_METHOD']=="POST"){
      // In testing, if you get an Bad referer error
      // comment out or remove the next three lines
      if (strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'])>7 ||
         !strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']))
         die("Bad referer");
      $msg="Values submitted by the user:\n";
      foreach($_POST as $key => $val){
         if (is_array($val)){
            $msg.="Item: $key\n";
            foreach($val as $v){
               $v = stripslashes($v);
               $msg.="   $v\n";
            }
         } else {
            $val = stripslashes($val);
            $msg.="$key: $val\n";
         }
      }
      $recipient="***@****.com";
      $subject="Webform";
      error_reporting(0);
      if (mail($recipient, $subject, $msg)){
         echo "<p>Message successfully sent</p>\n";
         echo nl2br($input);
      } else
         echo "An error occurred and the message could not be sent.";
   } else
      echo "";
  
  if (($string == $userstring) && (strlen($string) > 4)) {
header("Location: $success");
exit();
} else {
header("Location: $failure");
exit();
}
  
?>

 

settings.php

<?php

// This string contains allowable characters for the image.
// To reduce confusion, zero and the letter 'o' have been removed,
// and QuickCaptcha is NOT case-sensitive.
$acceptedChars = 'ABCDEFGHIJKLMNPQRSTUVWXYZ123456789';

// Number of characters in image.
$stringlength = 5;

// Where to go when the correct / incorrect code is entered.
$success = "*****/download.php";
$failure = "failure.html";

// A value between 0 and 100 describing how much color overlap
// there is between text and other objects.  Lower is more
// secure against bots, but also harder to read.
$contrast = 60;

// Various obfuscation techniques.
$num_polygons = 3; // Number of triangles to draw.  0 = none
$num_ellipses = 6;  // Number of ellipses to draw.  0 = none
$num_lines = 0;  // Number of lines to draw.  0 = none
$num_dots = 0;  // Number of dots to draw.  0 = none

$min_thickness = 2;  // Minimum thickness in pixels of lines
$max_thickness = 8;  // Maximum thickness in pixles of lines
$min_radius = 5;  // Minimum radius in pixels of ellipses
$max_radius = 15;  // Maximum radius in pixels of ellipses

// How opaque should the obscuring objects be. 0 is opaque, 127
// is transparent.
$object_alpha = 75;
?>

 

I really hope somebody can tell me where I've been going wrong...

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.