piercam03 Posted September 16, 2006 Share Posted September 16, 2006 hi i have some code...[code]<?// Website Contact Form Generator // http://www.tele-pro.co.uk/scripts/contact_form/ // This script is free to use as long as you // retain the credit link // get posted data into local variables$EmailTo = "piercam03@gmail.com";$Name = Trim(stripslashes($_POST['Name'])); $Email = Trim(stripslashes($_POST['Email'])); $Subject = Trim(stripslashes($_POST['Subject'])); $Message = Trim(stripslashes($_POST['Message'])); $Rating= Trim(stripslashes($_POST['Rating'])); $IP= $_SERVER["REMOTE_ADDR"];// validation$validationOK=true;if (!$validationOK) { echo "Error"; exit;}//THE ERRORSif (Trim($Name)=="") { echo"The Name Filed Was Empty"; exit;}elseif (Trim($Email)=="") { echo"The Email Field Was Empty"; exit;}elseif (Trim($Message)=="") { echo"The Message Field Was Empty"; exit;}// prepare email body text$Body = "";$Body .= "Name: ";$Body .= $Name;$Body .= "\n";$Body .= "Email: ";$Body .= $Email;$Body .= "\n";$Body .= "Subject: ";$Body .= $Subject;$Body .= "\n";$Body .= "Message: ";$Body .= $Message;$Body .= "\n";$Body .= "Rating: ";$Body .= $Rating;$Body .= "\n";$Body .= "IP: ";$Body .= $IP;$Body .= "\n";// send email $success = mail($EmailTo, $Subject, $Body, "From: <$Email>");// redirect to success page if ($success){ echo"<div id=\"main\"><h2>SUCCESS!</h2>Here is the information sent as you provided:<br>Name: $Name <br>Email: $Email <br>Message: $Message <br>Rating: $Rating <br>Your IP address was also stored, IP: $IP <br><br>Press F5 on your keyboard to return to where you were previously or select a page from the navigation bar on the left. <br><br>";}else{ echo"<br><h2>ERROR</h2> Sorry, there was an error. <br><br> *NOTE* you MUST NOT click the contact page on the navigation bar or all the fields you filled in will be reset, If however you press the BACK button on your browser you will return to the form with your previous information saved.";}?>[/code]basically when you fill out my form (www.iplay.co.nr/contact.php) its uses this file to send your details, the only problem is i can only get it to show one error at a time so even if the name and email fields are blank it only says the name one is, then once youve filled in the name one it tells you that the email is blank, how can i get it to show all of my errors together Quote Link to comment Share on other sites More sharing options...
shocker-z Posted September 16, 2006 Share Posted September 16, 2006 [code]//THE ERRORS$errors=array();if (Trim($Name)=="") { $errors[]="The Name Filed Was Empty";}elseif (Trim($Email)=="") { $errors[]="The Email Field Was Empty";}elseif (Trim($Message)=="") { $errors[]="The Message Field Was Empty";}if (!empty($errors)) { foreach ($errors as $error) { echo $error.'<Br>'; } exit;}[/code]should do the trick :) Quote Link to comment Share on other sites More sharing options...
Orio Posted September 16, 2006 Share Posted September 16, 2006 Change this:[code]//THE ERRORSif (Trim($Name)=="") { echo"The Name Filed Was Empty"; exit;}elseif (Trim($Email)=="") { echo"The Email Field Was Empty"; exit;}elseif (Trim($Message)=="") { echo"The Message Field Was Empty"; exit;}[/code]To this:[code]//THE ERRORS$err="";if ($Name=="") {$err.="The Name Filed Was Empty<br>";}if ($Email=="") {$err.="The Email Field Was Empty<br>";}if ($Message=="") {$err.="The Message Field Was Empty";}if(!empty($err)){die($err);}[/code]Orio.EDIT- shocker-z is quicker =PP Quote Link to comment Share on other sites More sharing options...
ronverdonk Posted September 16, 2006 Share Posted September 16, 2006 [code]$errors= array();if ($errors) { print '<span class="rood"><ul><li><b>'; print implode('</b></li><li><b>',$errors); print '</b></li></ul></span>'; exit;}if (Trim($Name)=="") { $errors[] = "The Name Filed Was Empty";}elseif (Trim($Email)=="") { $errors[] = "The Email Field Was Empty";}elseif (Trim($Message)=="") { $errors[] = "The Message Field Was Empty";}[/code] Quote Link to comment Share on other sites More sharing options...
piercam03 Posted September 16, 2006 Author Share Posted September 16, 2006 im sorry to say but only orio's worked but thankyou every one else for trying woooooooo Quote Link to comment Share on other sites More sharing options...
shocker-z Posted September 16, 2006 Share Posted September 16, 2006 i had an exit; in one of the if's thats why but ive edited now and should work :) Quote Link to comment Share on other sites More sharing options...
piercam03 Posted September 16, 2006 Author Share Posted September 16, 2006 cool Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.