welard Posted March 19, 2012 Share Posted March 19, 2012 <?php $ip = $_POST['ip']; $httpref = $_POST['httpref']; $httpagent = $_POST['httpagent']; $visitor = $_POST['visitor']; $visitormail = $_POST['visitormail']; $notes = $_POST['notes']; $attn = $_POST['attn']; #================================================================================================== #this looks for email if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) #================================================================================================== { echo "<h2>Use Back - Enter valid e-mail</h2>\n"; $badinput = "<h2>Feedback was NOT submitted</h2>\n"; echo $badinput; die ("Go back! ! "); } #================================================================================================== #this making sure all fields have been filled if(empty($visitor) || empty($visitormail) || empty($notes )) { #================================================================================================== echo "<h2>Use Back - Please fill in all fields</h2>\n"; die ("Use back! ! "); } #================================================================================================== #This is looking for captcha ====================================================================== session_start(); if ($_POST['captcha'] == $_SESSION['captcha']) #==================================================================================================== { $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"; if ($attn == "Chairperson") mail("emailhere", $subject, $message, $from); if ($attn == "Securtary") mail("email here", $subject, $message, $from); if ($attn == "Treausure") mail("email here", $subject, $message, $from); if ($attn == "Training") mail("email here", $subject, $message, $from); if ($attn == "Expeditions") mail("email here", $subject, $message, $from); if ($attn == "Webmaster") mail("email here", $subject, $message, $from); ?> ok the thing is that it sends a email to Chairperson email but it will not send to the rest shuld i be useing "elseif"? Quote Link to comment https://forums.phpfreaks.com/topic/259242-my-mail-script-problems/ Share on other sites More sharing options...
Muddy_Funster Posted March 19, 2012 Share Posted March 19, 2012 elseif() shouldn't matter in this case, Could you humour me and wrap all your if actions in {}, even the ones that are only a single line. Quote Link to comment https://forums.phpfreaks.com/topic/259242-my-mail-script-problems/#findComment-1328960 Share on other sites More sharing options...
welard Posted March 19, 2012 Author Share Posted March 19, 2012 if ($attn == "Chairperson") { mail("email here", $subject, $message, $from); } if ($attn == "Securtary") { mail("email here", $subject, $message, $from); } if ($attn == "Treausure") { mail("email here", $subject, $message, $from); } if ($attn == "Training") { mail("email here", $subject, $message, $from); } if ($attn == "Expeditions") { mail("email here", $subject, $message, $from); } if ($attn == "Webmaster") { mail("email here", $subject, $message, $from); } ?> thanks for the responce but it did not work am i missing any thing else? Quote Link to comment https://forums.phpfreaks.com/topic/259242-my-mail-script-problems/#findComment-1328976 Share on other sites More sharing options...
Muddy_Funster Posted March 19, 2012 Share Posted March 19, 2012 hmmm....have you closed this one yet? if ($_POST['captcha'] == $_SESSION['captcha']) #==================================================================================================== { Quote Link to comment https://forums.phpfreaks.com/topic/259242-my-mail-script-problems/#findComment-1328980 Share on other sites More sharing options...
welard Posted March 19, 2012 Author Share Posted March 19, 2012 <html> <head> <script type="text/javascript" language="JavaScript1.2" SRC="scripts/stm31.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Sendemail Script</title> <style type="text/css"> <!-- body { background-color: #00CCFF; } --> </style></head> <body> <!-- Reminder: Add the link for the 'next page' (at the bottom) --> <!-- Reminder: Change 'YourEmail' to Your real email --> <?php $ip = $_POST['ip']; $httpref = $_POST['httpref']; $httpagent = $_POST['httpagent']; $visitor = $_POST['visitor']; $visitormail = $_POST['visitormail']; $notes = $_POST['notes']; $attn = $_POST['attn']; #================================================================================================== #this looks for email if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) #================================================================================================== { echo "<h2>Use Back - Enter valid e-mail</h2>\n"; $badinput = "<h2>Feedback was NOT submitted</h2>\n"; echo $badinput; die ("Go back! ! "); } #================================================================================================== #this making sure all fields have been filled if(empty($visitor) || empty($visitormail) || empty($notes )) { #================================================================================================== echo "<h2>Use Back - Please fill in all fields</h2>\n"; die ("Use back! ! "); } #================================================================================================== #This is looking for captcha ====================================================================== session_start(); if ($_POST['captcha'] == $_SESSION['captcha']) #==================================================================================================== { $todayis = date("l, F j, Y, g:i a") ; // trying to make it +4 hours more than server time $todayis = time() - (int)substr(date('O'),0,3)*60*60; $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"; if ($attn == "Chairperson") { mail("email here", $subject, $message, $from); } if ($attn == "Securtary") { mail("email here", $subject, $message, $from); } if ($attn == "Treausure") { mail("email here", $subject, $message, $from); } if ($attn == "Training") { mail("email here", $subject, $message, $from); } if ($attn == "Expeditions") { mail("email here", $subject, $message, $from); } if ($attn == "Webmaster") { mail("email here", $subject, $message, $from); } ?> <?php include "mainmenu.php";?> <p align="center"> <strong>Date:</strong> <?php echo $todayis ?> <br /> <strong>Thank You :</strong> <?php echo $visitor ?> <br/> ( <?php echo $visitormail ?> ) <br /> <strong>Attention:</strong> <?php echo $attn ?> <br /> <strong>Message:</strong><br /> <?php $notesout = str_replace("\r", "<br/>", $notes); echo $notesout; ?> <br /> <?php echo "Your IP $ip"; ?> <?php } #This "else" is for captcha if it is not right nothing will be sent else die (" <p align='center'> Captcha was not right please go back and retry "); ?> <br /><br /> <a href="index.php"> Home </a></p> </body> </html> here is all the code the captcha is closed at the bottem of the page Quote Link to comment https://forums.phpfreaks.com/topic/259242-my-mail-script-problems/#findComment-1328983 Share on other sites More sharing options...
Muddy_Funster Posted March 19, 2012 Share Posted March 19, 2012 I'm gonna go have a play with that - will post a revision for you when I'm done. Quote Link to comment https://forums.phpfreaks.com/topic/259242-my-mail-script-problems/#findComment-1328986 Share on other sites More sharing options...
Muddy_Funster Posted March 19, 2012 Share Posted March 19, 2012 let me know how this works out for you: <?php session_start(); $html1 = <<<HTML_1 <html> <head> <script type="text/javascript" language="JavaScript1.2" SRC="scripts/stm31.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Sendemail Script</title> <style type="text/css"> <!-- body { background-color:#00CCFF; } --> </style></head> <body> <!-- Reminder: Add the link for the 'next page' (at the bottom) --> <!-- Reminder: Change 'YourEmail' to Your real email --> HTML_1; echo $html1; $ip = $_POST['ip']; $httpref = $_POST['httpref']; $httpagent = $_POST['httpagent']; $visitor = $_POST['visitor']; $visitormail = $_POST['visitormail']; $notes = $_POST['notes']; $attn = $_POST['attn']; #================================================================================================== #this looks for email if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) #================================================================================================== { echo "<h2>Use Back - Enter valid e-mail</h2>\n"; $badinput = "<h2>Feedback was NOT submitted</h2>\n"; echo $badinput; die ("Go back! ! "); } #================================================================================================== #this making sure all fields have been filled if(empty($visitor) || empty($visitormail) || empty($notes )) { #================================================================================================== echo "<h2>Use Back - Please fill in all fields</h2>\n"; die ("Use back! ! "); } #================================================================================================== #This is looking for captcha ====================================================================== if ($_POST['captcha'] == $_SESSION['captcha']) #==================================================================================================== { $todayis = date("l, F j, Y, g:i a") ; // trying to make it +4 hours more than server time $todayis = time() - (int)substr(date('O'),0,3)*60*60; //this may help with your time offset: /* <?php $date = date_create('2000-01-01'); date_add($date, date_interval_create_from_date_string('10 days')); echo date_format($date, 'Y-m-d'); ?> */ $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"; $attn = strtolower($attn); $attn = trim($attn); switch ($attn){ case "chairperson": mail("email here", $subject, $message, $from); break; case "securtary": mail("email here", $subject, $message, $from); break; case "treausure": mail("email here", $subject, $message, $from); break; case "training": mail("email here", $subject, $message, $from); break; case "expeditions": mail("email here", $subject, $message, $from); break; case "webmaster": mail("email here", $subject, $message, $from); break; default: die ("could not find $attn in contacts"); break; } include "mainmenu.php"; $notesout = str_replace("\r", "<br/>", $notes); $html2 = <<<HTML_2 <p align="center"> <strong>Date:</strong> $todayis <br /> <strong>Thank You :</strong> $visitor <br/> ( $visitormail ) <br /> <strong>Attention:</strong> $subject <br /> <strong>Message:</strong><br /> $notesout <br /> Your IP $ip HTML_2; echo $html2; } #This "else" is for captcha if it is not right nothing will be sent else{ die (" <p align='center'> Captcha was not right please go back and retry ");} ?> <br /><br /> <a href="index.php"> Home </a></p> </body> </html> Another thing, check your spelling for the $attn values against your form values (don't worry about the case - I forced it to lower case for the comparrison. Normaly I would have the form values set to key values for an array in that setup, less chance of slipping a typo in when it's only a single number. Quote Link to comment https://forums.phpfreaks.com/topic/259242-my-mail-script-problems/#findComment-1328993 Share on other sites More sharing options...
welard Posted March 19, 2012 Author Share Posted March 19, 2012 lol big thankyou again for the help it is now working thanks to you and my spelling mistakes Quote Link to comment https://forums.phpfreaks.com/topic/259242-my-mail-script-problems/#findComment-1329014 Share on other sites More sharing options...
Muddy_Funster Posted March 19, 2012 Share Posted March 19, 2012 no worries, being dyslexic double checking spelling is a matter of course for me Quote Link to comment https://forums.phpfreaks.com/topic/259242-my-mail-script-problems/#findComment-1329024 Share on other sites More sharing options...
welard Posted March 19, 2012 Author Share Posted March 19, 2012 i hear that lol i hate d and b if i right with them there uppercase so i know with 1s they are lol Quote Link to comment https://forums.phpfreaks.com/topic/259242-my-mail-script-problems/#findComment-1329049 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.