I have a web form, that I am trying to process and send to an email address... but the variables are not being transfered between the pages. Can someone help me figure out why?
I tried REALLY simplifying the code, but it still didn't work. It's obviously something to do with the initial form (take a look below), or something wrong with the server transfering variables (if this is the case, what do I ask my webhost?) ....
Below is the complete code (minus the javascript for form validation ... which should not affect the variables transferring between pages)
Initial form for submission....
<div class="side-formbox">
<form name="contact_form" method="post" action="contactform.php" onSubmit="return evalid()">
<div class="formlabel"> Name *</div>
<div class="formfield"><input name="fname" type="text" /></div>
<div class="formlabel"> E-mail *</div>
<div class="formfield"><input type="text" name="mail" size="30" /></div>
<div class="formlabel">Phone</div>
<div class="formfield"><input name="phone" type="text" size="30" onkeypress="return numere(event)" onkeyup="return limitarelungime(this, 10)" /></div>
<div class="formlabel">Message *</div>
<div class="formfield"><textarea name="message" onkeyup="return limitarelungime(this, 255)" rows="5"></textarea></div>
<div class="formlabel">Security Code*</div>
<div class="formcode"><input id="chapcha_code" name="chapcha_code" type="text" /></div>
<div class="formcodeimg"><img src="security_image.php" border="0" /></div>
<div class="clear"></div>
<div class="formlabel">
<!-- <input type="reset" name="reset" value="Reset"/> -->
<input type="submit" name="Submit" value="Submit" id="Submit">
</div>
</form>
</div>
Code from the processing page (contactform.php)...
<?php session_start(); ?>
<!-- Head tag, title, and then the start of the body tag and some content -->
<?php
echo "submitPOST: ".$_POST['Submit']."<br /><br />";
echo "messagePOST: ".$_POST['message']."<br /><br />";
echo "messageGET: ".$_GET['message']."<br /><br />";
// These three variables (above) output empty results,
// even when I put in a value and submit it .....
// So, without any values for these, the rest of
// the form doesn't really work.
if(isset($_POST['Submit'])) {
if( $_SESSION['chapcha_code'] == $_POST['chapcha_code'] && !empty($_SESSION['chapcha_code'] ) ) {
$youremail = 'test@mydomain.com';
$fromsubject = 'Form Contact Page';
$title = $_POST['title'];
$fname = $_POST['fname'];
$mail = $_POST['mail'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$to = $youremail;
$mailsubject = 'Form Contact Page';
$body = $fromsubject.'
Name: '.$fname.'
Phone Number: '.$phone.'
E-mail: '.$mail.'
Message:
'.$message.'
|---------END MESSAGE----------|';
echo "Thank you fo your message. Someone will contact you shortly.";
mail($to, $subject, $body);
unset($_SESSION['chapcha_code']);
} else {
echo 'Sorry, you have provided an invalid security code<br /><br />';
?>
<form name="contact_form" method="post" action="contactform.php" onSubmit="return evalid()">
<div class="formlabel">Name *</div>
<div class="formfield"><input name="fname" type="text" /></div>
<div class="formlabel">E-mail *</div>
<div class="formfield"><input type="text" name="mail" size="30" /></div>
<div class="formlabel">Phone</div>
<div class="formfield"><input name="phone" type="text" size="30" onkeypress="return numere(event)"
onkeyup="return limitarelungime(this, 10)" /></div>
<div class="formlabel">Message *</div>
<div class="formfield"><textarea name="message" onkeyup="return limitarelungime(this, 255)" cols="35" rows="5"></textarea></div>
<div class="formlabel">Security Code*</div>
<div class="formcode"><input id="chapcha_code" name="chapcha_code" type="text" /></div>
<div class="formcodeimg"><img src="security_image.php" border="0" /></div>
<div class="clear"></div>
<div class="formlabel">
<!-- <input type="reset" name="reset" value="Reset"/> -->
<input type="submit" name="Submit" value="Submit" id="Submit">
</div>
</form>
<?php
}
} else {
echo "You must write a message. </br> Please go to <a href='/contact.php'>Contact Page</a>";
echo $message;
}
?>
Please help ... I've tried 3 different types of email submission forms ... and they all had the same problems...