kaspm Posted May 5, 2006 Share Posted May 5, 2006 I have a multipage form, that I want to be sent to my email once it has been submitted. Im new to php so any help you give me I appreciate.I have a 4 page form and have all the values "hidden" on the last page. In order to email the form, should I put this code on the last page.[code]<?php$to = 'myemail@whatever.com';$subject = 'the subject';$message = 'Value1''Value2''Value3''AndSoOn';$headers = 'From: website@whatever.com' . "\r\n" .mail($to, $subject, $message, $headers);?> [/code] Quote Link to comment https://forums.phpfreaks.com/topic/9146-mail-question/ Share on other sites More sharing options...
corillo181 Posted May 5, 2006 Share Posted May 5, 2006 i don't know much php either, but is obvious to notice that the way you put the message is bad..the values are not join in any way.. i think 'value1,value2,value3';but then again i don't know where you getting your values from.. thats just a bad way to joing values.. Quote Link to comment https://forums.phpfreaks.com/topic/9146-mail-question/#findComment-33655 Share on other sites More sharing options...
ober Posted May 5, 2006 Share Posted May 5, 2006 That's exactly right... just make the message contain the variables. Take a shot at it and let us know what you get.You may also want to set the return value of the mail function to a variable so you can test to see if it succeeded or not. Quote Link to comment https://forums.phpfreaks.com/topic/9146-mail-question/#findComment-33656 Share on other sites More sharing options...
kaspm Posted May 5, 2006 Author Share Posted May 5, 2006 Ok. Im getting my "values" from my form, The values are from the "name" of the form fieldExample<input type="text" name="Value1"> Quote Link to comment https://forums.phpfreaks.com/topic/9146-mail-question/#findComment-33663 Share on other sites More sharing options...
ober Posted May 5, 2006 Share Posted May 5, 2006 What is the method of the form? GET or POST?The variables will be passed to the processing script as $_GET['name'] or $_POST['name']. GET passes them in the URL... POST passes them without showing them in the URL. Quote Link to comment https://forums.phpfreaks.com/topic/9146-mail-question/#findComment-33665 Share on other sites More sharing options...
corillo181 Posted May 5, 2006 Share Posted May 5, 2006 ok here what you should do..the name field are values.. right..so all you need to do is in the script make those names in to variables..such as .. $name = $_post['thenameofthefield'];if you want to mail it to you use the $_post method.. $_get is for url..after that in your message you cna just use the variable..$messege = " hello $name";if you want a bunch of variable you can just dump them inside the double quotes.. Quote Link to comment https://forums.phpfreaks.com/topic/9146-mail-question/#findComment-33668 Share on other sites More sharing options...
kaspm Posted May 5, 2006 Author Share Posted May 5, 2006 Ok here is the code I got so far there are a lot more fields I want to send but I was trying it out. Now when i go to the last page of the form it doesnt show its just a plain white page. What could be the problem?Thanks<?php$to = 'myemail@whatever.com';$subject = 'Test;$name = $_post['StartMonth','StartYear'];$message = "$name";$headers = 'From: website@whatever.com' . "\r\n" .mail($to, $subject, $message, $headers);?> Quote Link to comment https://forums.phpfreaks.com/topic/9146-mail-question/#findComment-33681 Share on other sites More sharing options...
ober Posted May 5, 2006 Share Posted May 5, 2006 You're not displaying any message ... it's probably sending the mail, but you don't have a success message or anything. Quote Link to comment https://forums.phpfreaks.com/topic/9146-mail-question/#findComment-33684 Share on other sites More sharing options...
kaspm Posted May 5, 2006 Author Share Posted May 5, 2006 its not even sending the mail Quote Link to comment https://forums.phpfreaks.com/topic/9146-mail-question/#findComment-33685 Share on other sites More sharing options...
corillo181 Posted May 5, 2006 Share Posted May 5, 2006 [!--quoteo(post=371648:date=May 5 2006, 03:00 PM:name=kaspm)--][div class=\'quotetop\']QUOTE(kaspm @ May 5 2006, 03:00 PM) [snapback]371648[/snapback][/div][div class=\'quotemain\'][!--quotec--]Ok here is the code I got so far there are a lot more fields I want to send but I was trying it out. Now when i go to the last page of the form it doesnt show its just a plain white page. What could be the problem?Thanks<?php$to = 'myemail@whatever.com';$subject = 'Test;$name = $_post['StartMonth','StartYear'];$message = "$name";$headers = 'From: website@whatever.com' . "\r\n" .mail($to, $subject, $message, $headers);?>[/quote]maybe it didn't sent because you did not do the $subject right..when working with php you really name to take your time and make sure nothing is missing.. if you just getting stared use zend! it wont let you make much mistakes..now in $subject you have ='Test;you see missing a '$subject='test';another problem i just notice.. in the $header.. you got .'\n\r".this i think is wrong.. you dont need another . dot at the end becuase you are not connection nothing else to the headers.. so the "\\" should be with no ending dot.. the first dot connects it the last just doing nothing.. Quote Link to comment https://forums.phpfreaks.com/topic/9146-mail-question/#findComment-33689 Share on other sites More sharing options...
ober Posted May 5, 2006 Share Posted May 5, 2006 You actually need a semi-colon after the $headers line. Quote Link to comment https://forums.phpfreaks.com/topic/9146-mail-question/#findComment-33693 Share on other sites More sharing options...
corillo181 Posted May 5, 2006 Share Posted May 5, 2006 [!--quoteo(post=371661:date=May 5 2006, 03:36 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ May 5 2006, 03:36 PM) [snapback]371661[/snapback][/div][div class=\'quotemain\'][!--quotec--]You actually need a semi-colon after the $headers line.[/quote]i even missed that.. see i'm too used to color programs.. lol Quote Link to comment https://forums.phpfreaks.com/topic/9146-mail-question/#findComment-33697 Share on other sites More sharing options...
kaspm Posted May 5, 2006 Author Share Posted May 5, 2006 I appreciate the help guys but even that doesnt correct the problem Quote Link to comment https://forums.phpfreaks.com/topic/9146-mail-question/#findComment-33706 Share on other sites More sharing options...
ober Posted May 5, 2006 Share Posted May 5, 2006 It should look like this:[code]<?php$to = 'myemail@whatever.com';$subject = 'Test';$name = $_POST['StartMonth'] . $_POST['StartYear'];$message = $name;$headers = 'From: website@whatever.com' . "\r\n";mail($to, $subject, $message, $headers);?>[/code]POST must be in caps and you can't grab 2 variables at a time. Quote Link to comment https://forums.phpfreaks.com/topic/9146-mail-question/#findComment-33708 Share on other sites More sharing options...
kaspm Posted May 5, 2006 Author Share Posted May 5, 2006 I would like to thank everyone who helped me with this. I now have it working. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/9146-mail-question/#findComment-33731 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.