PHP form value sent by email - can't make it work |
PHP form value sent by email - can't make it work |
gregous |
Oct 28 2008, 04:19 PM
Post
#1
|
Group: Members Posts: 1 Joined: 28-October 08 Member No.: 6,999 |
Hello
I'm new to PHP and I've been looking for information in google and forums but i'm not able to translate it to worlk for my scritp. Basically i have a form with name, email and message and i want to add a fields called 'cartype' and received the users's choice in the email message. My contact.php form is as follow: ******************************************************************** contact.php ************** <form action="mail.php" method="post"> <h4><strong><u>Contacter nous</u></strong></h4> <p align="left">Nom : <input type="text" name="naam"> </p> <p align="left">Addresse email : <input type="text" name="email"> </p> <p align="left"> Message : </p> <p> <textarea name="Message" cols="50" rows="8" ></textarea> </p> <p>Type of car</p> <p> <select name="CarType" id="CarType"> <option value="berline">Berline</option> <option value="minivan">Mini Van</option> <option value="other">Sans importance</option> </select> </p> <input type="submit" value="Send"> </form> *************************************************** mail.php **************** And my mail.php function is as follow: <?php ini_set("SMTP", "relay.skynet.be"); $Nom=$_POST['Nom']; $email=$_POST['email']; $Message=$_POST['Message']; if (isset($_POST["email"]) && $_POST["email"] !="") { if (mail("gregorypommerol@gmail.com", "Reservation", "$Message", "From: $email", "-f $email")) { echo "<h3><p>The email has been sent.</p></h3>"; } else { echo "<p>Sorry, your message hasn't been sent!</p>"; } } ?> ==> What is just need is to include in my PHP the right script to get by email in the message body the choice that the user will make in choosing the CarType value that is either berline, minivan or other. Could you please help me ? I saw that it needs to be a field array but the full formula, i can't make it work here Thanks a lot |
Brian Chandler |
Oct 29 2008, 01:36 AM
Post
#2
|
Jocular coder Group: Members Posts: 2,460 Joined: 31-August 06 Member No.: 43 |
Your php script gets a variable $_POST['Message'], which is the value of the "Message" string -- it also gets one called $_POST['CarType']. So all you have to do is join these things together, using '.' which is the string concatenation operator, and you're done.
Incidentally, I recommend using all lowercase for things like form variable names. It will save you having to remember exactly which places require the case to match, and which don't. (PHP is normally case sensitive; URLs are not, mostly.) |
Lo-Fi Version | Time is now: 25th April 2024 - 09:42 AM |