Sebolains Posted August 29, 2009 Share Posted August 29, 2009 Hey guys. I had this code for a contact page that sent an email to me with the information that people filled in in the form. It used to work perfectly, but now I've changed hosts and it doesn't work anymore. Everything else in the site works perfectly. I'm going insane trying to see why this is. See if you can pleaase give me a hand. Here's the code: <h2>Contact Us</h2> <br> <?php $myemail = 'myemailadress@yahoo.com'; $subject = 'Contact form Subject'; $op = $_POST[op]; if($op == 'contact') { $name = stripslashes($_POST[name]); $email = stripslashes($_POST[email]); $text = stripslashes($_POST[text]); $referer = $_POST[referer]; $remote_host = $_SERVER[REMOTE_ADDR]; $server = $_SERVER[sERVER_NAME]; $browser = $_SERVER[HTTP_USER_AGENT]; if(!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$",$email)) { $status = "We're sorry, but you've entered an incorrect email address.<br>"; } if(!$name) { $status .= "Please enter your name.<br>"; } if(!$text) { $status .= "Please enter a message.<br>"; } if(!$status) { $header = "From: $emailrnReply-To: $emailrn"; $message = " Name: $name Referer: $referer Site: $server Remote Host: $remote_host Remote Browser: $browser $text "; if(mail($myemail, $subject, $message, $header)) { $status = "Thank you for your Feedback!!<br><br>"; } else { $status = "There was a problem sending your feedback, please try again later.<br><br>"; } } else { $status .= "<br>Please press <u>back</u> on your browser to resubmit.<br><br>"; } } $referer = $_SERVER[HTTP_REFERER]; if(!preg_match('#^http\:\/\/[a-z0-9-]+.([a-z0-9-]+.)?[a-z]+#i', $referer)) { unset($referer); } ?> <?php print $status; ?> <form method="post" action="<?php print $_SELF; ?>"> <input type="hidden" name="op" value="contact"> <input type="hidden" name="referer" value="<?php print $referer; ?>"> Name<br><input name="name" size="35" value=""><br> E-mail address<br><input name="email" size="35" value=""><br> <br>Message<br><textarea name="text" cols="50" rows="10"></textarea><br><br> <input type="submit" value="Send message!"> </form> the problem is that I get the message error whenever I try to use it. Thanks a million for your contributions!! Quote Link to comment https://forums.phpfreaks.com/topic/172419-solved-help-with-contact-code/ Share on other sites More sharing options...
ignace Posted August 29, 2009 Share Posted August 29, 2009 if(!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$",$email)) eregi() is deprecated use PCRE instead of POSIX. add $status = ''; before the if (!eregi()) and change $status = "We're sorry, but you've entered an incorrect email address.<br>"; to $status .= "We're sorry, but you've entered an incorrect email address.<br>"; What is the specific problem does it output: $status = "There was a problem sending your feedback, please try again later.<br><br>";? Quote Link to comment https://forums.phpfreaks.com/topic/172419-solved-help-with-contact-code/#findComment-909059 Share on other sites More sharing options...
Sebolains Posted August 29, 2009 Author Share Posted August 29, 2009 First of all, thanks for your help. I tried doing your suggested changes, but the same thing keeps happening. And yes: the problem is that it keeps outputting $status = "There was a problem sending your feedback, please try again later.<br><br>";? Thank you so much for your help. I'll keep trying to see whether I can come up with what's wrong. Quote Link to comment https://forums.phpfreaks.com/topic/172419-solved-help-with-contact-code/#findComment-909070 Share on other sites More sharing options...
peranha Posted August 29, 2009 Share Posted August 29, 2009 Is mail set up in your php.ini file for the new hosting company? Quote Link to comment https://forums.phpfreaks.com/topic/172419-solved-help-with-contact-code/#findComment-909074 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.