ClioSport.net

Register a free account today to become a member!
Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

  • When you purchase through links on our site, we may earn an affiliate commission. Read more here.

Any see a problem with this php?



  306 TD Slut
Code:
<?php
// Website Contact Form Generator 
// [URL]http://www.tele-pro.co.uk/scripts/contact_form/[/URL] 
// This script is free to use as long as you  
// retain the credit link  
// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); 
$EmailTo = "[EMAIL="mark.simons@yahoo.co.uk"]mark.simons@yahoo.co.uk[/EMAIL]";
$Subject = "MESSAGE FROM WEBSITE";
$Name = Trim(stripslashes($_POST['Name'])); 
$Address = Trim(stripslashes($_POST['Address'])); 
$Telephone = Trim(stripslashes($_POST['Telephone'])); 
$RequiredJobDate = Trim(stripslashes($_POST['RequiredJobDate'])); 
$Enquiry = Trim(stripslashes($_POST['Enquiry'])); 
// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
  exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Address: ";
$Body .= $Address;
$Body .= "\n";
$Body .= "Telephone: ";
$Body .= $Telephone;
$Body .= "\n";
$Body .= "RequiredJobDate: ";
$Body .= $RequiredJobDate;
$Body .= "\n";
$Body .= "Enquiry: ";
$Body .= $Enquiry;
$Body .= "\n";
// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.html\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
}
?>

doesnt seem to be loading up the ok.html or error.html

the browser just stays at contact.php and it says done in the bottom left corner..
 

KDF

  Audi TT Stronic
Well don't use meta to redirect, your much better off using header() (see third example)

Let me know if that fixes it.. ;)
 
  306 TD Slut
its weird, it was working fine last night. but doesnt wotk this morning. i havent intentionally changed anything on it..
 
  306 TD Slut
sorted thanks matey.

in that code, which is the part that makes a field mandatory for filling in? i'd like to make the name, telephone and enquiry field mandatory fields.
 

KDF

  Audi TT Stronic
Change the validation bit from

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



to this.. (just a simple check for empty fields)


Code:
// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (empty($Name)) $validationOK=false;
if (empty($Telephone)) $validationOK=false;
if (empty($Enquiry)) $validationOK=false;

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


Also, I havent changed it but I dont know why the script is using trim() twice on the emailfrom field. Also I dont know if you change it from meta refresh to the header() tag as I said above so have left it as is..
 


Top