user222427
user222427

Reputation:

PHP recaptcha send mail issues

Hey guys, if anybody can help me out i'd love it...

What i have is a form, that went sent, uses doublecheck.php

<?php  
    require_once('recaptchalib.php');  
    $privatekey = "";  
    $resp = recaptcha_check_answer ($privatekey,  
    $_SERVER["REMOTE_ADDR"],   
    $_POST["recaptcha_challenge_field"],  
    $_POST["recaptcha_response_field"]);  
    if (!$resp->is_valid) {  
        die ("Sorry please go back and try it again." .  
            "" . $resp->error . ")");  
    }  
    if ($resp->is_valid) {  
        require_once('sendmail.php');  
    }    
?>

And then my sendmail.php

<?php

    $ip = $_POST['ip'];
    $httpref = $_POST['httpref'];
    $httpagent = $_POST['httpagent'];
    $visitor = $_POST['visitor'];
    $notes = $_POST['notes'];
    $attn = $_POST['attn'];

    $todayis = date("l, F j, Y, g:i a");

    $attn = $attn ;
    $subject = $attn;

    $notes = stripcslashes($notes);

    $message = " $todayis [EST] \n
Attention: $attn \n
Message: $notes \n
From: $visitor ($Your Prayer or Concern)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

    $from = "From:\r\n";

    mail("", Prayers and Concerns, $message);

?>

<p align="center">
Date: <?php echo $todayis ?>
<br />
<br />

Attention: <?php echo $attn ?>
<br />
Message:<br />
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip ?>

<br /><br />
<a href="contact.php"> Next Page </a>
</p>
</body>
</html>

What i'm having a hard time with is when its succesful i need to send out $notes but $notes is always blank. Should i just put my sendmail php inside of my successful php? Or can someone explain to me why $notes is blank.

I do have my recaptcha key in, and also i do have an email address. I kept some things private, also there is a notes textarea in my HTML

Here is my html for that table:

<form action="doublecheck.php" action="http://www.ipower.com/scripts/formemail.bml" enctype="application/x-www-form-urlencoded" method="post">
  <table>
    <tbody style="font-size: 12px;">
      <tr>
        <td width="661">Your Prayer or Concern<br/>
          <textarea name="notes" rows="6" cols="100" maxlength="1024"></textarea></td>
      </tr>
      <tr>
        <td><script type="text/javascript" src="http://api.recaptcha.net/challenge?k=6LdoKLoSAAAAAChm6Oaquimz8g1elKd5OQBJtCLm"></script>

<noscript>
    <iframe src="http://api.recaptcha.net/noscript?k=6LdoKLoSAAAAAChm6Oaquimz8g1elKd5OQBJtCLm" height="300" width="500" frameborder="0"></iframe><br/>
    <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
    <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
</noscript>                <p>
              <input type="submit" id="Pray" name="Pray" value="Send your prayer"/>
          </p></td>
      </tr>
      <tr>
      </tr>
    </tbody>

  </table>
</form>

Upvotes: 0

Views: 794

Answers (1)

Don Kirkby
Don Kirkby

Reputation: 56700

I suggest you get the LiveHeaders plug in for Firefox and look at exactly what form data you're submitting to make sure that the notes field is there. If it is, then try using var_dump to dump the $_POST array and make sure that it's being received properly.

The PHP Development Tools plug in for the Eclipse IDE has a pretty good debugger. Stepping through in a debugger is usually easier for this kind of problem than adding a bunch of debugging code.

Upvotes: 1

Related Questions