kingberrill Posted May 24, 2010 Share Posted May 24, 2010 hi all, I have a a booking form which works just like a contact form but I am getting "error" when I send the message below is the form <form action="contact.php" method="post" id="contactform"> <ol> <li> <label for="name">First Name <span class="red">*</span></label> <input id="name" name="name" class="text" /> </li> <li> <label for="email">Your email <span class="red">*</span></label> <input id="email" name="email" class="text" /> </li> <li> <label for="company">Contact No.</label> <input id="company" name="company" class="text" /> </li> <li> <label for="subject">Subject</label> <input id="subject" name="subject" class="text" /> </li> <li> <label for="message">Message <span class="red">*</span></label> <textarea id="message" name="message" rows="6" cols="50"></textarea> </li> <li class="buttons"> <input type="image" name="imageField" id="imageField" src="images/send.gif" /> </li> </ol> </form> and here is the contract script (contact.php) <?php if(!$_POST) exit; $email = $_POST['email']; if (!preg_match('/[a-z0-9!#$%&\'*+\/=?\^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?\^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/', $email)) { $error.="Invalid email address entered"; $errors=1; } else { // email is ok! } if (!empty($errors)) { if ($errors==1) echo $error; } else{ $values = array ('name','email','message'); $required = array('name','email','message'); $your_email = "[email protected]"; $email_subject = "New Message: ".$_POST['subject']; $email_content = "new message:\n"; foreach($values as $key => $value){ if(in_array($value,$required)){ if ($key != 'subject' && $key != 'company') { if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; } } $email_content .= $value.': '.$_POST[$value]."\n"; } } if(@mail($your_email,$email_subject,$email_content)) { echo 'Message sent!'; } else { echo 'ERROR!'; } } ?> feel free to use the contact form on the site www.mossfarmcattery.co.uk [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/202766-i-get-error-when-running-my-contact-form-via-php-script/ Share on other sites More sharing options...
Bladescope Posted May 24, 2010 Share Posted May 24, 2010 Tried using it without the '@' symbol? mail() returns FALSE if something has stopped it (and TRUE if it has been accepted). Link to comment https://forums.phpfreaks.com/topic/202766-i-get-error-when-running-my-contact-form-via-php-script/#findComment-1062726 Share on other sites More sharing options...
ScotDiddle Posted May 24, 2010 Share Posted May 24, 2010 kingberrill, I down-loaded your html and php script, and I get : Message sent!. Somthing is wrong with you OS sendmail system. Scot L. Diddle, Richmond VA Link to comment https://forums.phpfreaks.com/topic/202766-i-get-error-when-running-my-contact-form-via-php-script/#findComment-1062727 Share on other sites More sharing options...
kingberrill Posted May 24, 2010 Author Share Posted May 24, 2010 ok, I think i know wots wrong, the site is not hosted with me at the moment so maybe hes the other hosts problem because I have a script the same on another site and its fine so Ill just have to wait till the domain is on my hosting, thanks guys Link to comment https://forums.phpfreaks.com/topic/202766-i-get-error-when-running-my-contact-form-via-php-script/#findComment-1062771 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.