
08-02-2008, 00:23
|
|
|
|
חבר מתאריך: 21.06.07
הודעות: 14
|
|
|
contact us form php
שלום לכולם
יש לי קובץ php ל contct us . הבעייה היא כאשר אני לוחץ על "שלח" ולא כל השדות חובה מלאים הוא מפנה אותי לדף error.html ובדף יש הודעה, שההודעה לא נשלחה. אני צריך לשנות את קובץ ה php
כך שאם אחד משדות החובה לא מלאים שאני אקבל הודעה באותו הדף מבלי שהפרטים שהכנסתי ימחקו
קוד PHP:
$EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); $EmailTo = "shenhavb@hotmail.com"; $Subject = "Estimate"; $FirstName = Trim(stripslashes($_POST['FirstName'])); $LastName = Trim(stripslashes($_POST['LastName'])); $Address = Trim(stripslashes($_POST['Address'])); $City = Trim(stripslashes($_POST['City'])); $State = Trim(stripslashes($_POST['State'])); $Zip = Trim(stripslashes($_POST['Zip'])); $DayPhone = Trim(stripslashes($_POST['DayPhone'])); $EvningPhone = Trim(stripslashes($_POST['EvningPhone'])); $Besttimetocall = Trim(stripslashes($_POST['Besttimetocall'])); $Comment = Trim(stripslashes($_POST['Comment'])); // validation $validationOK=true; if (Trim($EmailFrom)=="") $validationOK=false; if (Trim($FirstName)=="") $validationOK=false; if (Trim($DayPhone)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">"; exit; } // prepare email body text $Body = ""; $Body .= "FirstName: "; $Body .= $FirstName; $Body .= "\n"; $Body .= "LastName: "; $Body .= $LastName; $Body .= "\n"; $Body .= "Address: "; $Body .= $Address; $Body .= "\n"; $Body .= "City: "; $Body .= $City; $Body .= "\n"; $Body .= "State: "; $Body .= $State; $Body .= "\n"; $Body .= "Zip: "; $Body .= $Zip; $Body .= "\n"; $Body .= "DayPhone: "; $Body .= $DayPhone; $Body .= "\n"; $Body .= "EvningPhone: "; $Body .= $EvningPhone; $Body .= "\n"; $Body .= "Besttimetocall: "; $Body .= $Besttimetocall; $Body .= "\n"; $Body .= "Comment: "; $Body .= $Comment; $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\">"; }
|