Jump to content

Archived

This topic is now archived and is closed to further replies.

kaspm

mail( Question

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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..

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Ok. Im getting my "values" from my form, The values are from the "name" of the form field
Example

<input type="text" name="Value1">

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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..

Share this post


Link to post
Share on other sites
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);
?>

Share this post


Link to post
Share on other sites
You're not displaying any message ... it's probably sending the mail, but you don't have a success message or anything.

Share this post


Link to post
Share on other sites
[!--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..

Share this post


Link to post
Share on other sites
You actually need a semi-colon after the $headers line.

Share this post


Link to post
Share on other sites
[!--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

Share this post


Link to post
Share on other sites
I appreciate the help guys but even that doesnt correct the problem

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
I would like to thank everyone who helped me with this. I now have it working. Thanks

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.