michaelpalmer7 Posted November 1, 2006 Share Posted November 1, 2006 Hi there i'm new to php but am learning fast, i ammaking a website with a contact us page with a form with subject, message, surname, email etc. I have a endmail.php file that e-mails the e-mail address and message but i want to add the other fields so it will e-mail them i.e. surname etc. here is my curent script: <? $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; mail( "yourname@example.com", "Feedback Form Results", $message, "From: $email" ); header( "Location: http://thankyou.htm" );?>Any help would be greatly appreciated,Cheers.... Quote Link to comment Share on other sites More sharing options...
Anidazen Posted November 1, 2006 Share Posted November 1, 2006 Not entirely sure what you're after here Michael!You want them to enter their surname, address etc. and have it displayed along the message in the email you receive?The key to this is $message. That's basically what you get sent. At the moment, the user puts their message in $message, and it gets sent - as is - to you. What we're gonna need to do is change it before sending it.Something like this:$newmessage = "Name: $nameContact Email: $contactemailAddress: $addressOther Value1: $othervalueOther value2: $othervalueCustomer's Message:". $message;Adding these lines to your existing script should do the trick. In this example, $name, $contactemail, $address, $othervalue1, $othervalue2 are all values passed by your form.PS: You shouldn't have to do "$email = $_REQUEST['email'];" for your values? Should work without. Try it. If you do need to do this for values, you'll need to do it for the new ones too. Quote Link to comment Share on other sites More sharing options...
Anidazen Posted November 1, 2006 Share Posted November 1, 2006 Forgot to mention, you'd need to change the 'message' value you're sending to the mail() function to $newmessage, from $message.PS: If you don't get this I can show the whole edited script for ya, just ask. This way though I'm trying to show ya why the changes work and what's been done. Easy to understand - just the value you pass in that mail() function where $message is should be changed to whatever you want yourself to be sent. :) Quote Link to comment Share on other sites More sharing options...
michaelpalmer7 Posted November 1, 2006 Author Share Posted November 1, 2006 thanks for the replyi tried adding the script and changing it slightly, but i was getting bombarded by parse errors etc.it would be a great help if you could write the script, i think i'm a bit too new to this, the fields are named:subject,mesage,title, firstname,surname,telephone and email. and you were right i just want them to appear on the email i recieve, heres my sendmail.php script again <? $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; mail( "yourname@example.com", "Feedback Form Results", $message, "From: $email" ); header( "Location: http://thankyou.htm" );?>any help would be greatly appreciated,cheers Quote Link to comment Share on other sites More sharing options...
Anidazen Posted November 1, 2006 Share Posted November 1, 2006 <?$newmessage1 = "Customer Contact Form Results.Subject: $subjectFull Name: $title $firstname $secondnameTelephone: $telephoneEmail Address: $emailMessage Body:$message"; mail( "yourname@example.com", "Feedback Form: " . $subject, $newmessage1, "From: $email" ); header( "Location: http://thankyou.htm" );?>any help would be greatly appreciated,cheers[/quote]That should do the trick, the subject chosen will appear in the email subject as well as an added touch, lol.It's pretty important that you understand what I did though - the message we send is simply this variable in your code - the one I've highlighted:mail( "yourname@example.com", "Feedback Form Results", [b]$message[/b], "From: $email" ); - I renamed it but it doesn't make a difference. Whatever $message is (or $newmessage, now I changed it) is what gets sent. It's a variable like any other, so I simply made it like any other. :) Quote Link to comment Share on other sites More sharing options...
michaelpalmer7 Posted November 2, 2006 Author Share Posted November 2, 2006 hi me again still strugglingthis is my sendmail script now:<?$newmessage1 = "Customer Contact Form Results.Subject: $subjectFull Name: $title $firstname $surnameTelephone: $telephoneEmail Address: $emailMessage Body:$message"; mail( "yourname@example.com", "Feedback Form: " . $subject, $newmessage1, "From: $email" ); header( "Location: http:thankyou.htm" );?>I put it online with my e-mail and thankyou page etc. and when i pressed submit it said:Notice: Undefined variable: subject in sendmail.php on line 6Notice: Undefined variable: title in sendmail.php on line 6Notice: Undefined variable: firstname in sendmail.php on line 6Notice: Undefined variable: surname in sendmail.php on line 7Notice: Undefined variable: telephone in sendmail.php on line 8Notice: Undefined variable: email in sendmail.php on line 10Notice: Undefined variable: message in sendmail.php on line 12Notice: Undefined variable: subject in sendmail.php on line 15Notice: Undefined variable: email in sendmail.php on line 16Warning: Cannot modify header information - headers already sent by (output started at sendmail.php:6) in sendmail.php on line 17i have tried changing a bit since but no luck please help if you can Quote Link to comment Share on other sites More sharing options...
Anidazen Posted November 5, 2006 Share Posted November 5, 2006 Hmm, seems that in your environment/form method you do need to use these things: $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] Do that for all of the variables, and put the lines at or near the top of the script. See if that helps.The header warning... I'm not entirely sure.This redirect is definitely causing the problem:[i]header( "Location: http:thankyou.htm" );[/i]And the problem is that this is a header based redirect, so it can't happen after even a single line of html has been passed. However, I don't know why it thinks some has. Possibly changing the first thing would help here - I don't know.Add those extended variable definitions and post back. Quote Link to comment 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.