ROCKINDANO Posted August 20, 2009 Share Posted August 20, 2009 Hi everyone, i am working on a feedback form and its not sending the email. can someone help? this is what i have: this is the form page. feedbackform.php <div id="middle"> <form method="post" action="processfeedback.php"> <p>Your Name:<br /><input type="text" name="custname" /><br /> Your Email: <br /><input type="text" name="email" /><br /> Your Feedback: <br /><textarea name="feedback" cols="50" rows="10"></textarea><br /> what department: Solid Waste: <input type="radio" name="searchtype" checked="checked" value="solid" /> Public Works: <input type="radio" name="searchtype" value="public" /><br /><br /></p> <input name="submit" type="submit" value="submit" /><input type="reset" name="Reset" value="Clear Fields" /> </form> </div><!-- END OF MIDDLE CONTAINER --> this is the processfeedback.php <?php //create short variable names $custname = $HTTP_POST_VARS['custname']; $email = $HTTP_POST_VARS['email']; $feedback = $HTTP_POST_VARS['feedback']; if (!ereg('^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$', $email)) { print "that is not a valid email address. Please return to the previous page and try again."; } $toaddress = 'dvera@ci.edinburg.tx.us'; if(eregi('test', $feedback)) $toaddress = 'd_veraz@hotmail.com'; else if(eregi('test', $feedback)) $toaddress = 'rockindano@hotmail.com'; $subject = 'Feed Back from website'; $mailcontent = 'Customer Name: '.$custname."\n" .'Customer email: '.$email."\n" ."Customer's feedback: \n".$feedback."\n"; $fromaddress = 'From: dvera@ci.edinburg.tx.us'; mail($toaddress, $subject, $mailcontent, $fromaddress); ?> Quote Link to comment https://forums.phpfreaks.com/topic/171189-feedback-form/ Share on other sites More sharing options...
mikesta707 Posted August 20, 2009 Share Posted August 20, 2009 one thing I spotted if(eregi('test', $feedback)) $toaddress = 'd_veraz@hotmail.com'; else if(eregi('test', $feedback)) $toaddress = 'rockindano@hotmail.com'; this block tests the same thing twice, but has two different outcomes. Perhaps its sending an email to an address you don't expect it to because of this. Also, I think eregi() is deprecated Quote Link to comment https://forums.phpfreaks.com/topic/171189-feedback-form/#findComment-902741 Share on other sites More sharing options...
ROCKINDANO Posted August 20, 2009 Author Share Posted August 20, 2009 well i took that out and still does not send anything. Is there a better way of checking the email field? Quote Link to comment https://forums.phpfreaks.com/topic/171189-feedback-form/#findComment-902744 Share on other sites More sharing options...
mikesta707 Posted August 20, 2009 Share Posted August 20, 2009 well how exactly are you testing it. It seems that you just check if the feedback response has the word "test" in it, and if so it sends to a specific email address. Oh on a completely unrelated note. the following code: if (!ereg('^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$', $email)) { print "that is not a valid email address. Please return to the previous page and try again."; #insert a die() or an exit() command here if you want to terminate the script } doesn't do anything but print its not a valid email address. if you want to stop it, use an exit() or something. back on topic, what email address should it be send to? try writing if (mail($toaddress, $subject, $mailcontent, $fromaddress)){ echo "Success!"; } else { echo "Epic Fail"; } instead of just mail($toaddress, $subject, $mailcontent, $fromaddress); and see what happens Quote Link to comment https://forums.phpfreaks.com/topic/171189-feedback-form/#findComment-902751 Share on other sites More sharing options...
ROCKINDANO Posted August 20, 2009 Author Share Posted August 20, 2009 well i am trying to test out using my own email. it has to send it to the "$toaddress = 'dvera@ci.edinburg.tx.us'; by default. now if it finds the word test in the email it should send it to the d_veraz@hotmail.com. but it doesn't pass where it checks if its a valid email part and dies. Quote Link to comment https://forums.phpfreaks.com/topic/171189-feedback-form/#findComment-902755 Share on other sites More sharing options...
ROCKINDANO Posted August 20, 2009 Author Share Posted August 20, 2009 well i tried that " if (mail($toaddress, $subject, $mailcontent, $fromaddress)){ echo "Success!"; } else { echo "Epic Fail"; } " and if goes to the else part "Epic fail". Quote Link to comment https://forums.phpfreaks.com/topic/171189-feedback-form/#findComment-902766 Share on other sites More sharing options...
nysmenu Posted August 21, 2009 Share Posted August 21, 2009 What exactly are you getting in your inbox? Quote Link to comment https://forums.phpfreaks.com/topic/171189-feedback-form/#findComment-902996 Share on other sites More sharing options...
newbtophp Posted August 21, 2009 Share Posted August 21, 2009 Replace your old processfeedback.php with: <?php //Customer Name $custname = $_REQUEST['custname'] ; //Customers Email $email = $_REQUEST['email'] ; //Customers Feedback $message = $_REQUEST['feedback'] ; //Subject $subject = "Feed Back from website"; //You (to address) $to = "dvera@ci.edinburg.tx.us"; $headers = "From: $email"; $sent = mail($to, $subject, $message, $headers) ; if($sent) {print "W000t! It works!"; } else {print "Damn! It dont work"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/171189-feedback-form/#findComment-903003 Share on other sites More sharing options...
ROCKINDANO Posted August 26, 2009 Author Share Posted August 26, 2009 Well tried that code and still won't send the email. its been a few days and this one is really killing me. any help? Do i need to turn on a settings in PHP or Apache? Quote Link to comment https://forums.phpfreaks.com/topic/171189-feedback-form/#findComment-906878 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.