Jump to content

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


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\">"; 
} 
?>

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.