Jump to content

Post Variable not going through.


jerkomatic

Recommended Posts

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.