Jump to content

mail( Question


kaspm

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]

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.