arohamack Posted January 27, 2011 Share Posted January 27, 2011 Hi FYI I'm a n00b in this particular forum & php n00b really but I'm having a problem & cant find a solution anywhere! I need to be able to send an email from a form. Within the form is a dropdown field for different regions. When a region is selected it sets the email address for that region into an input/text field. I need to pickup that value and send the email to that address but not sure how. Have been told to use echo$email & that perhaps my variable is empty but I haven't got a clue where to put it or what that means. Help please?! my code: include ('maketable.php'); include ('mailbot.php'); include ('auditFile.php'); $office = $_REQUEST["office"]; $callername = $_REQUEST["callername"]; $callerphone = $_REQUEST["callerphone"]; $callaction = $_REQUEST["callaction"]; $callerInfo = "Callers Name=".$callername; $commentInfo = "Callers Phone No=".$callerphone; $callDetail = "Action Taken=".$callaction; $title = "DOC Call Results"; $stylesheet = "stylesheet.css"; $logo = "tcclogo.jpg"; $display = makeHeader($title,$stylesheet,$logo); $display .= makeTable("Caller Details",$callerInfo,1); $display .= makeTable("",$commentInfo,1); $display .= makeTable("",$callDetail,1); $display .= '</body></html>'; $info = $callerInfo."; ".$commentInfo."; ".$callDetail; auditFile($title, $info); echo $email; mailbot($title,$display,"email","[email protected]","ThankYou.html"); Quote Link to comment https://forums.phpfreaks.com/topic/225813-send-email-to-field-value-code-problem/ Share on other sites More sharing options...
Bradley99 Posted January 27, 2011 Share Posted January 27, 2011 $subject = "Subject"; $message = " Thankyou.html This is an automated response, please do not reply!"; mail($email, $subject, $message, "From: Name<Youemail>"); Maybe try something like that with the $email. Quote Link to comment https://forums.phpfreaks.com/topic/225813-send-email-to-field-value-code-problem/#findComment-1165813 Share on other sites More sharing options...
arohamack Posted January 27, 2011 Author Share Posted January 27, 2011 Thanks Bradley for your quick reply. I probably should have mentioned that the email is handled from another file called mailbot.php. The email is working well with no problems, i just really need it to go to the email address that's set in the 'email' field once the region has been selected. Quote Link to comment https://forums.phpfreaks.com/topic/225813-send-email-to-field-value-code-problem/#findComment-1165815 Share on other sites More sharing options...
Bradley99 Posted January 27, 2011 Share Posted January 27, 2011 Ahh i see, So maybe it's something to do with your other file? Quote Link to comment https://forums.phpfreaks.com/topic/225813-send-email-to-field-value-code-problem/#findComment-1165817 Share on other sites More sharing options...
arohamack Posted January 27, 2011 Author Share Posted January 27, 2011 hmmm... I dont think so (?). mailbot.php code: <?php function mailbot($title,$display,$recipients,$from,$redirect){ $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'FROM:'.$from; mail($recipients,$title,$display,$headers); if ($redirect != Null){ header ("Location: ".$redirect); } } ?> Atho in saying that, i've just noticed the $recipients part of it so maybe I need to investigate that a bit more. Quote Link to comment https://forums.phpfreaks.com/topic/225813-send-email-to-field-value-code-problem/#findComment-1165818 Share on other sites More sharing options...
arohamack Posted January 28, 2011 Author Share Posted January 28, 2011 ok, i've checked out the other file and no, changing it around doesn't seem to help at all. but then again, i am a n00b at this so who knows! does anyone else have any idea? Quote Link to comment https://forums.phpfreaks.com/topic/225813-send-email-to-field-value-code-problem/#findComment-1166364 Share on other sites More sharing options...
arohamack Posted January 30, 2011 Author Share Posted January 30, 2011 hmmm.... from what I can tell it's definitely NOT the external file that's causing any problems. I really just need to know where to put the 'echo$email' bit and how in this line... mailbot($title,$display,"[b]emailfieldvalue as the email address[/b]","[email protected]","ThankYou.html"); I write the field name. Sorry for the bump without really any further information but the guy that normally helps me with this stuff is away and my boss is waiting for some results Quote Link to comment https://forums.phpfreaks.com/topic/225813-send-email-to-field-value-code-problem/#findComment-1167275 Share on other sites More sharing options...
BlueSkyIS Posted January 30, 2011 Share Posted January 30, 2011 don't echo. mailbot($title,$display,$email,"[email protected]","ThankYou.html"); Quote Link to comment https://forums.phpfreaks.com/topic/225813-send-email-to-field-value-code-problem/#findComment-1167298 Share on other sites More sharing options...
arohamack Posted January 31, 2011 Author Share Posted January 31, 2011 Thanks for that but unfortunately it doesn't work. No email arrived. Quote Link to comment https://forums.phpfreaks.com/topic/225813-send-email-to-field-value-code-problem/#findComment-1167586 Share on other sites More sharing options...
arohamack Posted January 31, 2011 Author Share Posted January 31, 2011 right, i've found a problem with my code I had $callaction = $_REQUEST["callaction"]; missing for starters. I'm not sure if I had the input field named correctly either, although either way, I STILL cant get it going. Quote Link to comment https://forums.phpfreaks.com/topic/225813-send-email-to-field-value-code-problem/#findComment-1167708 Share on other sites More sharing options...
suma237 Posted January 31, 2011 Share Posted January 31, 2011 please check this statement $info = $callerInfo."; ".$commentInfo."; ".$callDetail; echo all the variable before passing to the function . Quote Link to comment https://forums.phpfreaks.com/topic/225813-send-email-to-field-value-code-problem/#findComment-1167712 Share on other sites More sharing options...
arohamack Posted January 31, 2011 Author Share Posted January 31, 2011 Thankyou. Making changes now and testing them out. Quote Link to comment https://forums.phpfreaks.com/topic/225813-send-email-to-field-value-code-problem/#findComment-1167713 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.