html - How To Return String Value of Drop Down (Select) Menu in PHP -
i have list of items in drop-down menu, , have googled 45 minutes or so. nothing answering question. versed in css , html, new php; appreciated. want string value. not numerical value (which getting now.)
html:
<form action="mail.php" method="post"> <select name="list1"> <option value="0">select products...</option> <option value="1">wheat 50lbs</option> <option value="2">barley 50lbs</option> <option value="3">purple barley 50lbs</option> </select> ........ </form>
php:
<?php //data user $name = $_post['name']; $email = $_post['email']; $phone = $_post['phone']; $message = $_post['message']; $subject = $_post['subject']; $list1 = $_post['list1']; //how send e-mail $to = "clientsemailaddress@example.com"; $body = "name: $name \n email: $email \n phone: $phone \norder: $list1 \n\n $message"; $headers = "from: $name". "\r\n" . "reply-to: $email" . "\r\n" . "x-mailer: php/" . phpversion(); mail($to, $subject, $body, $headers); echo "message sent! <a href='contact.html'>click here</a>"; ?>
note: spaces shouldn't in code above aren't in actual code.
if want return string, , numerical value not important, set string actual value. instead of:
<select name="list1"> <option value="0">select products...</option> <option value="1">wheat 50lbs</option> <option value="2">barley 50lbs</option> <option value="3">purple barley 50lbs</option> </select>
it be:
<select name="list1"> <option value="">select products...</option> <option value="wheat 50lbs">wheat 50lbs</option> <option value="barley 50lbs">barley 50lbs</option> <option value="purple barley 50lbs">purple barley 50lbs</option> </select>
also, assuming wouldn't want them send first option, make sure validate , check have selected before submitting form.
Comments
Post a Comment