SebbieHE Posted January 30, 2013 Share Posted January 30, 2013 Hello. Please could someone tell me where to put MY email address so that when they send the message, I receive the email? <?php $owner_email = $_POST["owner_email"]; $headers = 'From:' . $_POST["email"]; $subject = 'A message from your site visitor ' . $_POST["name"]; $messageBody = ""; if($_POST['name']!='nope'){ $messageBody .= '<p>Visitor: ' . $_POST["name"] . '</p>' . "\n"; $messageBody .= '<br>' . "\n"; } if($_POST['email']!='nope'){ $messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n"; $messageBody .= '<br>' . "\n"; }else{ $headers = ''; } if($_POST['state']!='nope'){ $messageBody .= '<p>State: ' . $_POST['state'] . '</p>' . "\n"; $messageBody .= '<br>' . "\n"; } if($_POST['phone']!='nope'){ $messageBody .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n"; $messageBody .= '<br>' . "\n"; } if($_POST['fax']!='nope'){ $messageBody .= '<p>Fax Number: ' . $_POST['fax'] . '</p>' . "\n"; $messageBody .= '<br>' . "\n"; } if($_POST['message']!='nope'){ $messageBody .= '<p>Message: ' . $_POST['message'] . '</p>' . "\n"; } if($_POST["stripHTML"] == 'true'){ $messageBody = strip_tags($messageBody); } try{ if(!mail($owner_email, $subject, $messageBody, $headers)){ throw new Exception('mail failed'); }else{ echo 'mail sent'; } }catch(Exception $e){ echo $e->getMessage() ."\n"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/273831-where-do-i-put-my-email-address/ Share on other sites More sharing options...
Jessica Posted January 30, 2013 Share Posted January 30, 2013 If you look up mail() in the manual you can see what the arguments are. The first one is the email address to send the mail to. Quote Link to comment https://forums.phpfreaks.com/topic/273831-where-do-i-put-my-email-address/#findComment-1409169 Share on other sites More sharing options...
SebbieHE Posted January 30, 2013 Author Share Posted January 30, 2013 See. I put my email address there and the form still didn't work. Any advise? Quote Link to comment https://forums.phpfreaks.com/topic/273831-where-do-i-put-my-email-address/#findComment-1409171 Share on other sites More sharing options...
Jessica Posted January 30, 2013 Share Posted January 30, 2013 Why don't you show us THAT code. Quote Link to comment https://forums.phpfreaks.com/topic/273831-where-do-i-put-my-email-address/#findComment-1409172 Share on other sites More sharing options...
SebbieHE Posted January 30, 2013 Author Share Posted January 30, 2013 What do you mean by 'THAT'? The actual form? Quote Link to comment https://forums.phpfreaks.com/topic/273831-where-do-i-put-my-email-address/#findComment-1409174 Share on other sites More sharing options...
SebbieHE Posted January 30, 2013 Author Share Posted January 30, 2013 The form code is below. <form action="send_form.php" id="ContactForm"> <div class="success"> Contact form submitted! I will be in touch soon.</div> <fieldset class="left"> <div class="block"> <label class="name"> <span class="title1">Name:</span> <span class="bg"><input type="text" value="" class="input"></span> <span class="error">*This is not a valid name.</span> <span class="empty">*This field is required.</span> </label> <label class="email"> <span class="title1">Email:</span> <span class="bg"><input type="email" value="" class="input"></span> <span class="error">*This is not a valid email address.</span> <span class="empty">*This field is required.</span></label> <label class="phone"> <span class="title1">Phone:</span> <span class="bg"><input type="tel" value="" class="input"></span> <span class="error">*This is not a valid number.</span> <span class="empty">*This field is required.</span> </label> </div> <div class="block"> <label class="message"> <span class="title1">Message:</span> <span class="bg"><textarea rows="1" cols="2"></textarea></span> <span class="error">*The message is too short.</span> <span class="empty">*This field is required.</span> </label> </div> <div class="formButtons"> <div class="formBtn"> <a href="#" data-type="submit" class="moreButton">Send</a> </div> <div class="formBtn"> <a href="#" data-type="reset" class="moreButton">Clear</a> </div> </div> </fieldset> </form> Quote Link to comment https://forums.phpfreaks.com/topic/273831-where-do-i-put-my-email-address/#findComment-1409178 Share on other sites More sharing options...
Jessica Posted January 30, 2013 Share Posted January 30, 2013 The code where you put in your email. You should always post your latest code when you want help with it. Code that's two iterations old...wastes our time. Quote Link to comment https://forums.phpfreaks.com/topic/273831-where-do-i-put-my-email-address/#findComment-1409181 Share on other sites More sharing options...
SebbieHE Posted January 30, 2013 Author Share Posted January 30, 2013 The actual latest code: <?php $owner_email = $_POST["sebbieharrisonevans@gmail.com"]; $headers = 'From:' . $_POST["email"]; $subject = 'A message from your site visitor ' . $_POST["name"]; $messageBody = ""; if($_POST['name']!='nope'){ $messageBody .= '<p>Visitor: ' . $_POST["name"] . '</p>' . "\n"; $messageBody .= '<br>' . "\n"; } if($_POST['email']!='nope'){ $messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n"; $messageBody .= '<br>' . "\n"; }else{ $headers = ''; } if($_POST['state']!='nope'){ $messageBody .= '<p>State: ' . $_POST['state'] . '</p>' . "\n"; $messageBody .= '<br>' . "\n"; } if($_POST['phone']!='nope'){ $messageBody .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n"; $messageBody .= '<br>' . "\n"; } if($_POST['fax']!='nope'){ $messageBody .= '<p>Fax Number: ' . $_POST['fax'] . '</p>' . "\n"; $messageBody .= '<br>' . "\n"; } if($_POST['message']!='nope'){ $messageBody .= '<p>Message: ' . $_POST['message'] . '</p>' . "\n"; } if($_POST["stripHTML"] == 'true'){ $messageBody = strip_tags($messageBody); } try{ if(!mail($owner_email, $subject, $messageBody, $headers)){ throw new Exception('mail failed'); }else{ echo 'mail sent'; } }catch(Exception $e){ echo $e->getMessage() ."\n"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/273831-where-do-i-put-my-email-address/#findComment-1409185 Share on other sites More sharing options...
Jessica Posted January 30, 2013 Share Posted January 30, 2013 See, that's a lot more useful. Could have saved 5 or so posts. $_POST is an array. When you do $_POST['field_name'] you are looking for the value of the $_POST array at the field_name key. $owner_email = $_POST["sebbieharrisonevans@gmail.com"]; is looking for a posted field with the name of your email address. If you had error reporting on and set to show notices, you'd see this is wrong. Quote Link to comment https://forums.phpfreaks.com/topic/273831-where-do-i-put-my-email-address/#findComment-1409186 Share on other sites More sharing options...
SebbieHE Posted January 30, 2013 Author Share Posted January 30, 2013 I use notepad++. What software would you recommend? Thank you for the help by the way. Quote Link to comment https://forums.phpfreaks.com/topic/273831-where-do-i-put-my-email-address/#findComment-1409188 Share on other sites More sharing options...
Jessica Posted January 30, 2013 Share Posted January 30, 2013 Your problem has absolutely nothing to do with your text editor. Are you trying to learn PHP, or just change the form and then not learn more PHP? Quote Link to comment https://forums.phpfreaks.com/topic/273831-where-do-i-put-my-email-address/#findComment-1409190 Share on other sites More sharing options...
SebbieHE Posted January 30, 2013 Author Share Posted January 30, 2013 Trying to learn. Quote Link to comment https://forums.phpfreaks.com/topic/273831-where-do-i-put-my-email-address/#findComment-1409191 Share on other sites More sharing options...
thara Posted January 30, 2013 Share Posted January 30, 2013 (edited) when you post your code again please place it inside code tag by clicking on the button '<>' in your editor It will help others to read your code easily Edited January 30, 2013 by thara Quote Link to comment https://forums.phpfreaks.com/topic/273831-where-do-i-put-my-email-address/#findComment-1409193 Share on other sites More sharing options...
Jessica Posted January 30, 2013 Share Posted January 30, 2013 You need to put your email address as a string, and assign it to the variable. Go read the PHP manual. Quote Link to comment https://forums.phpfreaks.com/topic/273831-where-do-i-put-my-email-address/#findComment-1409208 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.