jerkomatic Posted July 6, 2007 Share Posted July 6, 2007 I finally got into working with AJAX and PHP and I programmed a contact page that will display the email content below the form once it's been submitted. Unfortunately, all of my $_Post variables aren't going through and I can't see what's wrong with the code. I'm thinking it's something very small. you can test it out on jerkomatic.com/contact.php The contact page code for the form is: <form id="frmCaptcha" method="post" name="frmCaptcha"> <table width="424" border="0" cellspacing="2" cellpadding="2" align="center"> <tr> <td align="left" valign="top">Fields marked (*) are required <hr noshade="noshade" /> </td> </tr> <tr> <td align="left" valign="top"><strong>*Your Email:</strong></td> </tr> <tr> <td align="left" valign="top"><input type="text" name="email" size="20" /></td> </tr> <tr> <td align="left" valign="top"><strong>Name:</strong></td> </tr> <tr> <td align="left" valign="top"><input type="text" name="name" size="20" /></td> </tr> <tr> <td align="left" valign="top"><strong>Reason For Contacting Us:</strong></td> </tr> <tr> <td align="left" valign="top"><select name="reason" id="Reason"> <option value="General">General Questions</option> <option value="Advertising">Advertising</option> <option value="Submissions">Submissions</option> <option value="Link Trade">Link Trade</option> </select></td> </tr> <tr> <td align="left" valign="top"><strong>Subject:</strong></td> </tr> <tr> <td align="left" valign="top"><input type="text" name="subject" size="40" /></td> </tr> <tr> <td align="left" valign="top"><strong>Comments:</strong></td> </tr> <tr> <td align="left" valign="top"><textarea name="comments" rows="5" cols="40"></textarea></td> </tr> <tr> <td align="left" valign="top"> <label for="captcha"><b>Captcha</b></label> </td> </tr> <tr> <td align="left" valign="top"> <img id="imgCaptcha" src="includes/create_image.php" /> <br /> <input id="txtCaptcha" type="text" name="txtCaptcha" value="" maxlength="10" size="32" /> <br /> <div id="result"> </div> </td> </tr> <tr> <td align="center" valign="top"> <input id="btnCaptcha" type="button" value="Send The Message" name="btnCaptcha" onclick="getParam(document.frmCaptcha)" /> </td> </tr> </table> </form> and the Captcha.php is where the issue is, I just can't find it. Please help if you see the error: <?php //Continue the session session_start(); print_r($_POST); die(); //Make sure that the input come from a posted form. Otherwise quit immediately if ($_SERVER["REQUEST_METHOD"] <> "POST") die("You can only reach this page by posting from the html form"); //Check if the securidy code and the session value are not blank //and if the input text matches the stored text if ( ($_REQUEST["txtCaptcha"] == $_SESSION["security_code"]) && (!empty($_REQUEST["txtCaptcha"]) && !empty($_SESSION["security_code"])) ) { $date = date("F d, Y g:ia T"); $name= $_POST['name']; $email= $_POST['email']; $reason= $_POST['reason']; $subject= $_POST['subject']; $comments= $_POST['comments']; $message="Message Sent on: $date<br><br> <table border='0' class='wteborder' cellpadding='0' cellspacing='2'> <tr> <td ><b>Name:</b></td> <td >$name</td> </tr> <tr> <td><b>Email:</b></td> <td>$email</td> </tr> <tr> <td><b>Reason:</b></td> <td>$reason</td> </tr> <tr> <td><b>Subject:</b></td> <td>$subject</td> </tr> <tr> <td ><b>Comments:</b></td> <td >$comments</td> </tr> </table>"; $to = 'admin@jerkomatic.com'; $subject = 'JerkOMatic '. $reason.' (From: '.$email.')'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From:' .$email. "\r\n"; mail($to, $subject, $message, $headers); echo "<h1>Successful!</h1><br> Thank you <b>".$name."</b> for submitting your message or comment. We will be contacting you shortly.<br><br>"; echo $message . '<br><br>'; } else { echo "<h1>Captcha Failed! Try again!</h1>"; } ?> Thanks in advance for your help. -dro admin@jerkomatic.com Quote Link to comment Share on other sites More sharing options...
per1os Posted July 6, 2007 Share Posted July 6, 2007 Wheres the javascript located at? It could be something to do with that. Quote Link to comment Share on other sites More sharing options...
soycharliente Posted July 6, 2007 Share Posted July 6, 2007 Did you try echoing the post array to see if they are going through and just not being set to anything? Quote Link to comment 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.