Jim R Posted August 22, 2009 Share Posted August 22, 2009 Upon submitting my form, the User is taken to dbenter.php, where it accurately inserts information into my database and redirects my User to the next step. The problem I'm having is I'm not sure how to send their form results from that PHP page. I've searched the web and here, but most of what I find are people asking about sending emails to the User. I just want the results sent to me. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/171370-insert-and-email-from-a-form-post-action/ Share on other sites More sharing options...
trq Posted August 22, 2009 Share Posted August 22, 2009 Call the mail function on dbenter.php. Quote Link to comment https://forums.phpfreaks.com/topic/171370-insert-and-email-from-a-form-post-action/#findComment-903808 Share on other sites More sharing options...
Jim R Posted August 22, 2009 Author Share Posted August 22, 2009 Here is my PHP prowess. I can take what I see, make sense of it and make it really do what I want. In calling the mail() function, I'm not sure how to make it work. I'm heading out for now and will search later. Is there a good place to start in seeing how it's coded? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/171370-insert-and-email-from-a-form-post-action/#findComment-903915 Share on other sites More sharing options...
PFMaBiSmAd Posted August 22, 2009 Share Posted August 22, 2009 most of what I find are people asking about sending emails to the User. I just want the results sent to me. So, if you put your email address in as the To: address in an email script, wouldn't that mean that the email would be sent to you? The point of programing is to write (or modify existing) code to accomplish a stated task. If you found an existing script that sends an email to anyone, to change it to send an email to you, you would identify the part of the code responsible for setting up the recipient and modify it to use your email address instead. And the light blue text in thorpe's post is a link to the php.ini documentation that describes, with examples, how to use the mail() function. Quote Link to comment https://forums.phpfreaks.com/topic/171370-insert-and-email-from-a-form-post-action/#findComment-903920 Share on other sites More sharing options...
Jim R Posted August 22, 2009 Author Share Posted August 22, 2009 I would have started with your last line, as it is I didn't catch the mail() being a link. Thanks, I'll get a look at it tonight. Quote Link to comment https://forums.phpfreaks.com/topic/171370-insert-and-email-from-a-form-post-action/#findComment-903927 Share on other sites More sharing options...
Jim R Posted August 23, 2009 Author Share Posted August 23, 2009 I can't get any of the variables to work in the $message variable. The regular text prints in the email, but that is all. <?php // The message $name = $_post['nameFirst'] . ' ' . $_post['nameLast']; $school = $_post['school']; $email = $_post['email']; $message = "$name"; $message = "has entered the fall league."; // In case any of our lines are larger than 70 characters, we should use wordwrap() $message = wordwrap($message, 70); // Send mail('basketball@metroindybasketball.com', 'Fall League Registration', $message); Quote Link to comment https://forums.phpfreaks.com/topic/171370-insert-and-email-from-a-form-post-action/#findComment-904627 Share on other sites More sharing options...
trq Posted August 24, 2009 Share Posted August 24, 2009 Your looking for the $_POST array, not $_post. There is a difference. Quote Link to comment https://forums.phpfreaks.com/topic/171370-insert-and-email-from-a-form-post-action/#findComment-904758 Share on other sites More sharing options...
Jim R Posted August 24, 2009 Author Share Posted August 24, 2009 WOW...thanks. Sometimes little things mean a lot. Quote Link to comment https://forums.phpfreaks.com/topic/171370-insert-and-email-from-a-form-post-action/#findComment-904762 Share on other sites More sharing options...
Jim R Posted August 24, 2009 Author Share Posted August 24, 2009 Made the changes. Still not working. Quote Link to comment https://forums.phpfreaks.com/topic/171370-insert-and-email-from-a-form-post-action/#findComment-904824 Share on other sites More sharing options...
Brandon_R Posted August 24, 2009 Share Posted August 24, 2009 Try this: <?php // The message $message = $_POST['nameFirst'] . ' ' . $_POST['nameLast'] .'\r\n'; $message .= $_POST['school'].'\r\n'; $message .= $_POST['email'].'\r\n'; $message .= $_POST['nameFirst'] . $_POST['nameLast'] ."has entered the fall league."; // In case any of our lines are larger than 70 characters, we should use wordwrap() $message = wordwrap($message, 70); // Send mail('basketball@metroindybasketball.com', 'Fall League Registration', $message); ?> Quote Link to comment https://forums.phpfreaks.com/topic/171370-insert-and-email-from-a-form-post-action/#findComment-904861 Share on other sites More sharing options...
Jim R Posted August 24, 2009 Author Share Posted August 24, 2009 It's carrying the values, which is good, but it's not recognizing any of the spacing. In what you provided, it just prints the /n/r. I changed it to <br>, and it just prints that too. Here is what I'm using as of the moment. <?php // The message $message = $_POST['nameFirst'] . $_POST['nameLast'] ." has entered the fall league.<br>"; $message .= $_POST['school'] . '<br>'; $message .= $_POST['email']; // In case any of our lines are larger than 70 characters, we should use wordwrap() $message = wordwrap($message, 70); // Send mail('basketball@metroindybasketball.com', 'Fall League Registration', $message); ?> Quote Link to comment https://forums.phpfreaks.com/topic/171370-insert-and-email-from-a-form-post-action/#findComment-905031 Share on other sites More sharing options...
trq Posted August 24, 2009 Share Posted August 24, 2009 <br> wont effect email because they are (by default) plain text (as they should be). You need to specifically set certain headers to have email sent as html. This is all covered in the link to the manual page I posted some 9 replies ago. Quote Link to comment https://forums.phpfreaks.com/topic/171370-insert-and-email-from-a-form-post-action/#findComment-905032 Share on other sites More sharing options...
PFMaBiSmAd Posted August 24, 2009 Share Posted August 24, 2009 '\r\n' should be "\r\n" (needs double-quotes so that the special characters will be parsed inside of the string as special characters) Quote Link to comment https://forums.phpfreaks.com/topic/171370-insert-and-email-from-a-form-post-action/#findComment-905037 Share on other sites More sharing options...
Jim R Posted August 24, 2009 Author Share Posted August 24, 2009 <br> wont effect email because they are (by default) plain text (as they should be). You need to specifically set certain headers to have email sent as html. This is all covered in the link to the manual page I posted some 9 replies ago. There isn't really anything that explains when to use double vs. single quotes, nor is there anything that explains <html> is set up differently. At least that is the case in the first parts of that page. Hard to tell what applies as the page continues, since there is a lot of other types of codes. In section 3 of the page you linked, the part marked with <html> looks a lot like it's set up like PHP. It's in the $message variable between single quotes. Quote Link to comment https://forums.phpfreaks.com/topic/171370-insert-and-email-from-a-form-post-action/#findComment-905066 Share on other sites More sharing options...
Jim R Posted August 24, 2009 Author Share Posted August 24, 2009 Had the / going the wrong way. It should be \. This is why I'm not really a coder. I'd be on suicide watch if this stuff was my job. Quote Link to comment https://forums.phpfreaks.com/topic/171370-insert-and-email-from-a-form-post-action/#findComment-905075 Share on other sites More sharing options...
Jim R Posted August 24, 2009 Author Share Posted August 24, 2009 I see the html header information now, but to the newb eye, it all reads like normal PHP. Quote Link to comment https://forums.phpfreaks.com/topic/171370-insert-and-email-from-a-form-post-action/#findComment-905078 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.