New here, I had a form that did work just fine and at some point over the last 6-12 months it has just stopped working.
Ive changed a few bits and bobs in an attempt to make it work and was wondering if anyone could shed some light on it. It appears that its not getting to the if (btnSubmit) part as any variables set up after that dont get assigned (checked with print ("$var"); on the webpage.
Any help would be appreciated as I cant think of anything else to try, Im no php expert i just barely get by!
<?php
$name = $_POST["name"];
$email = $_POST["email"];
$messagetext = $_POST["messagetext"];
GLOBAL $HTTP_POST_VARS, $btnSubmit, $messagetext, $email, $enquirytype, $from_email, $status;
if (!$status) {
$status="Unknown";
}
$from_email = "sales@vinylvisuals.co.uk";
if ($btnSubmit) {
echo "SUBMITTED FORM";
if (is_valid_email($email)) {
$to_email = $email;
$subject = "Vinlyvisuals - Enquiry";
$cust_body .= "To ".$HTTP_POST_VARS["name"]."\n \n";
$cust_body .= "I would like to thank you for contacing Vinylvisuals. \n";
$cust_body .= "We aim to respond to all enquiries within 24 hours although ";
$cust_body .= "you should allow 24 hours. \n \nThe details you have submitted can be ";
$cust_body .= "found below :\n \n";
$cust_body .= "Name : ".$HTTP_POST_VARS["name"]."\n";
$cust_body .= "Email : ".$HTTP_POST_VARS["email"]."\n";
$cust_body .= "Message : ".$HTTP_POST_VARS["messagetext"]."\n \n";
$cust_body .= "Vinylvisuals.co.uk \n";
$site_body .= "Please address the following enquiry. \n \n";
$site_body .= "Name : ".$HTTP_POST_VARS["name"]."\n";
$site_body .= "Email : ".$HTTP_POST_VARS["email"]."\n";
$site_body .= "Message : ".$HTTP_POST_VARS["messagetext"]."\n \n";
echo $cust_body;
echo $site_body;
// send mail to customer
// mail("$to_email", "$cust_body", "From: $from_email\nReply-To: $from_email\n");
// mail("$from_email", "$site_body", "From: $to_email\nReply-To: $to_email\n");
// send mail to customer
if (!mail("$to_email", "$cust_body", "From: $from_email\nReply-To: $from_email\n"))
echo "FAILED TO SEND MAIL 1";
if (!mail("$from_email", "$site_body", "From: $to_email\nReply-To: $to_email\n"))
echo "FAILED SEND MAIL 2";
$status = "Your email has been sent.";
exit_page("http://www.vinylvisuals.co.uk/thankyou.php");
} else {
$status = "Please enter a valid email address...";
}
}
?><FORM action="http://vinylvisuals.co.uk/index.php?pg=contact" method="post" enctype="multipart/form-data" name="contactForm">
If you have an enquiry please fill in the form below, we aim to respond within 24 hours although usually much quicker, or call us on 07528 731865.<br />
<br />
<table width="100%" border="0" align="center">
<tr>
<td width="175" height="32" align="right" class="bodytext"><strong>Name :</strong></td>
<td width="132" align="left"> <input name="name" type="text" size="20" class="formfield1" value="<?php print $HTTP_POST_VARS["name"]; ?>" /></td>
<td align="right"><span class="bodytext"><strong>Email :</strong></span> <input name="email" type="text" size="23" class="formfield1" value="<?php print $HTTP_POST_VARS["email"]; ?>" /></td>
</tr>
<tr>
<td width="175" align="right" valign="top" class="bodytext"><strong>Message :</strong></td>
<td colspan="2" align="left"><textarea name="messagetext" cols="50" rows="4" class="formfield1" value="<?php print $HTTP_POST_VARS["messagetext"]; ?>"></textarea></td>
</tr>
<tr class="bodytext">
<td colspan="3"> </td>
</tr>
<tr class="bodytext">
<td colspan="2" align="center"><br />
<br />
<br />
<br />
<br /></td>
<td align="right"><input type="reset" name="Reset" value="Reset" class="formfield1" />
<input type="submit" name="btnSubmit" value="Submit »" class="formfield1" /></td>
</tr>
<tr class="bodytext">
<td colspan="2" align="right"> Message Status: </td>
<td align="left"><?php print ("$status"); ?></td>
</tr>
<tr class="bodytext">
<td colspan="2" align="right">Form Name: </td>
<td align="left"><?php print ("$name"); ?></td>
</tr>
<tr class="bodytext">
<td colspan="2" align="right">Form Email: </td>
<td align="left"><?php print ("$email"); ?></td>
</tr>
<tr class="bodytext">
<td colspan="2" align="right">Form Message: </td>
<td align="left"><?php print ("$messagetext");?></td>
</tr>
<tr class="bodytext">
<td colspan="2" align="right">From Email: </td>
<td align="left"><?php print ("$from_email");?></td>
</tr>
<tr class="bodytext">
<td colspan="2" align="right">Email Subject: </td>
<td align="left"><?php print ("$subject");?></td>
</tr>
<tr class="bodytext">
<td colspan="2" align="right">Compiled Email Msg: </td>
<td align="left"><?php print ("$cust_body");?></td>
</tr>
<tr align="right" class="bodytext">
<td colspan="2">Compiled Owner Email Msg: </td>
<td align="left"><?php print ("$site_body");?></td>
</tr>
<tr align="right" class="bodytext">
<td colspan="2">Check Submit: </td>
<td align="left"><?php print ("$btnSubmit"); ?></td>
</tr>
</table>
</form>