Hi, I am having problems with my Email code on this page: http://www.mmsracing.ca/contact.php The code works perfectly if all the info is entered correctly. However, if you don't enter into one of the text boxes or don't do a valid Email the page you bring it to is totally out of wack. If you enter in a real email address and don't leave any of the text boxes blank the page it brings you to is completely fine. (You might have to try it out to see what exactly I mean) Thank you
Could you post the PHP code? Make sure you are checking for empty fields: if(isset($_POST['name']) && isset($_POST['email']) && isset($_POST['message'])){ mail(); // bla bla bla }
Here is the code: <?php $ip = $_POST['ip']; $httpref = $_POST['httpref']; $httpagent = $_POST['httpagent']; $visitor = $_POST['visitor']; $visitormail = $_POST['visitormail']; $notes = $_POST['notes']; $attn = $_POST['attn']; if (eregi('http:', $notes)) { die ("Do NOT try that! ! "); } if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) { echo "<font color=white>Use Back - Enter valid e-mail</font>\n"; $badinput ="\n"; echo $badinput; die ("Go back"); } if(empty($visitor) || empty($visitormail) || empty($notes )) { echo "<font color=white>Use Back - fill in all fields</font>\n"; die ("Use back"); } $todayis = date("l, F j, Y, g:i a") ; $attn = $attn ; $subject = $attn; $notes = stripcslashes($notes); $message = " $todayis [EST] \n Attention: $attn \n Message: $notes \n From: $visitor ($visitormail)\n Additional Info : IP = $ip \n Browser Info: $httpagent \n Referral : $httpref \n "; $from = "From: $visitormail\r\n"; mail("info@thedigitaloffering.com", $subject, $message, $from); ?>
You should not use $_POST['ip'] to get the users ip, to get their ip use: $ip = $_SERVER['REMOTE_ADDR']; The same goes for $httpref = $_POST['httpref']; $httpagent = $_POST['httpagent']; Also you should take this line out: $attn = $attn ;