Jump to content

php form not working - was working yesterday! please help.


mccannio

Recommended Posts

Posted: Wed Feb 07, 2007 9:04 am    Post subject: php not working - was working yesterday! please help   

 

--------------------------------------------------------------------------------

 

Hi there,

 

I have been pulling my hair out with this today. It is some code to process a form and then send the results via email. It was working fine yesterday but not it just keeps jumping to the error page!

 

I would really appreciate it if someone could help me!

 

Here is the code

 


<?php 

$EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); 
$EmailTo = "[email protected]".","; 
$Emailto.= $EmailFrom; 
$Subject = "Photocopier Enquiry"; 
$ColourCopiers = Trim(stripslashes($_POST['ColourCopiers'])); 
$BlackandWhiteCopiers = Trim(stripslashes($_POST['BlackandWhiteCopiers'])); 
$Facsimilies = Trim(stripslashes($_POST['Facsimilies'])); 
$Purchase = Trim(stripslashes($_POST['Purchase'])); 
$Lease = Trim(stripslashes($_POST['Lease'])); 
$Name = Trim(stripslashes($_POST['Name'])); 
$Company = Trim(stripslashes($_POST['Company'])); 
$PostCode = Trim(stripslashes($_POST['PostCode'])); 
$Email = Trim(stripslashes($_POST['EmailFrom'])); 
$Tel = Trim(stripslashes($_POST['Tel'])); 
$Message = Trim(stripslashes($_POST['Message'])); 
$Brochure = Trim(stripslashes($_POST['Brochure'])); 
$Model = Trim(stripslashes($_POST['Model'])); 



$validationOK=true; 
if (Trim($EmailFrom)=="") $validationOK=false; 
if (!$validationOK) { 
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; 
  exit; 
} 


$Body = ""; 
$Body .= "ColourCopiers: "; 
$Body .= $ColourCopiers; 
$Body .= "\n"; 
$Body .= "BlackandWhiteCopiers: "; 
$Body .= $BlackandWhiteCopiers; 
$Body .= "\n"; 
$Body .= "Facsimilies: "; 
$Body .= $Facsimilies; 
$Body .= "\n"; 
$Body .= "Purchase: "; 
$Body .= $Purchase; 
$Body .= "\n"; 
$Body .= "Lease: "; 
$Body .= $Lease; 
$Body .= "\n"; 
$Body .= "Name: "; 
$Body .= $Name; 
$Body .= "\n"; 
$Body .= "Company: "; 
$Body .= $Company; 
$Body .= "\n"; 
$Body .= "PostCode: "; 
$Body .= $PostCode; 
$Body .= "\n"; 
$Body .= "Email: "; 
$Body .= $Email; 
$Body .= "\n"; 
$Body .= "Tel: "; 
$Body .= $Tel; 
$Body .= "\n"; 
$Body .= "Message: "; 
$Body .= $Message; 
$Body .= "\n"; 
$Body .= "Brochure: "; 
$Body .= $Brochure; 
$Body .= "\n"; 
$Body .= "Model: "; 
$Body .= $Model; 
$Body .= "\n"; 


$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); 



if ($success){ 
  print "<meta http-equiv=\"refresh\" content=\"0;URL=thanks.htm\">"; 
} 
else{ 
  print "<meta http-equiv=\"refresh\" content=\"0;URL=contact.php\">"; 
} 
?> 

your error page is being displayed if $validationOK is false. Your $validationOK is false if trim($EmailFrom) == "".  $EmailFrom == "" if trim(stripslashes($_POST['EmailFrom'])) == "".  $_POST['EmailFrom'] would == "" for...what reasons? Perhaps there is nothing being input into the EmailFrom form field?  Perhaps it is misspelled?

 

btw, it is not necessary to trim something twice.

I'm not sure if this will have any difference, but it is worth a shot.

<?php
if (mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>")){ 
  print "<meta http-equiv=\"refresh\" content=\"0;URL=thanks.htm\">"; 
} 
else{ 
  print "<meta http-equiv=\"refresh\" content=\"0;URL=contact.php\">"; 
} 
?>

Archived

This topic is now archived and is closed to further replies.

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