tags:

views:

103

answers:

2

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"&gt;&lt;/script&gt;

<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>
A: 

Is your form's action set to the correct file ? Plus, are you receive the mail with the content of $notes? Can't you edit your question and place the form's header ?!?

(sorry, can't comment ...yet...)

Zuul
well my form is calling doublecheck first to verify recaptcha, if the recaptcha is successful then it calls the sendmail, i added the form header to edit
Mike
I don't believe to be possible having a form with two actions... since when user submits the form, it will act with the first action and doesn't return to use another action!What you can do is:<form name="testform" method="post" action="sendmail.php" onsubmit="doublecheck();">But the onsubmit will call a javascript file.. it's a matter of change your doublecheck.php to a js code :)With that, your form onsubmit will run the doublecheck and if it's ok, it will then run the sendmail (thus passing the mission value of $notes)I Think your problem is here...
Zuul
Could i just move the contents of the php script sendmail to the if(successful) part of doublecheck?, or couldnt i do the visa versa, add the doublecheck part to the sendmail script?
Mike
That's the fastest way... don't really know why you have that code separated, but if you put it all together, than the form will use the "action" attribute to one file and you're done...
Zuul
This problem has nothing to do with the position of his scripts. It's the fact that his form is not sending values. $_POST is a superglobal which will be available *anywhere* in PHP until it is unset manually. Converting his checks to JavaScript is a horrible idea, that just lets people disable JavaScript to avoid the Recaptcha check completely. @Mike: What is your `<form>` line that you're using?
animuson
@animuson, wake up man, the problem wasn't that at all, the problem was that in is form he had two action="something", off course that send-mail would never be run, because it was the second action...Btw: note that the form line it's on is question, just above the code for the table!Read the entire conversation all you'll get the picture :)
Zuul
Sorry, I didn't see that there because I wouldn't have expected to look *above* the code for the rest of it. Converting the check to JavaScript is still a horrible, horrible idea though. He just needs to remove the second action.
animuson
+1  A: 

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.

Don Kirkby