Fold out menu and php form.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Flutje
Forum Newbie
Posts: 3
Joined: Tue Apr 13, 2004 6:03 am

Fold out menu and php form.

Post by Flutje »

Hello all.

I have added a fold-out menu to my html but for the life of me I can't figure out how to add the choises you can make there to my mail form.

To have a look with what I mean when I say fold out menu look here:
http://www.albruna.nl/test/bestelencontact.html
you can see that you can choose from 7 different cars.

But how do I add the selection made by a visitor (if they make a selection if not no problem) to this mail form I use?

Can anyone help me out here I am a newbie to php so keep it simple if you can :D

<?
$mailto = "yourmail@addy.nl" ;
$subject = "Contactformulier" ;
$formurl = "http://www.albruna.nl/test/bestelencontact.htm" ;
$errorurl = "http://www.albruna.nl/fout.html" ;
$thankyouurl = "http://www.albruna.nl/dankuwel.html" ;
$naam = $_POST['naam'] ;
$voorletter = $_POST['voorletter'];
$adres = $_POST['adres'];
$postcode = $_POST['postcode'];
$plaats = $_POST['plaats'];
$land = $_POST['land'];
$email = $_POST['email'] ;
$testie = $_POST['testie'];
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );

if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($_POST['naam']) || empty($_POST['voorletter']) || empty($_POST['land']) || empty($_POST['comments'])) {
header( "Location: $errorurl" );
exit ;
}


$messageproper =

"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------- opmerkingen -------------------------\n\n" .
"naam:".$naam . "\n".
"voorletter:".$voorletter . "\n".
"adres:".$adres . "\n".
"postcode:".$postcode . "\n".
"plaats:".$plaats . "\n".
"land:".$land . "\n".
"email:".$email . "\n".
"testie:".$testie . "\n".
$comments .
"\n\n------------------------------------------------------------\n" ;

mail($mailto, $subject, $messageproper, "From: \"$naam\" <$email>\nReply-To: \"$naam\" <$email>\nX-Mailer: chfeedback.php 2.01" );
header( "Location: $thankyouurl" );
exit ;

?>

Regards,

Martin
TheBentinel.com
Forum Contributor
Posts: 282
Joined: Wed Mar 10, 2004 1:52 pm
Location: Columbus, Ohio

Post by TheBentinel.com »

By "fold out menu", are you referring to the Select list labelled "Fietskar:" on your form? If so, then when the user clicks submit, the browser will send you the value of the option that was selected. For instance, if the user selected "Schwinn Trailer", you would get back the value "2". Whatever is in the value="" attribute of the option the user selects is what you will get back.

I notice that some of your options have "name" attributes. I don't think that will do anything for you, though it is available in the DOM so if you or some other javascript is using it, don't take it out. Just an observation.
Flutje
Forum Newbie
Posts: 3
Joined: Tue Apr 13, 2004 6:03 am

Post by Flutje »

I am indeed referring to the fietskar selected list fold out menu:-)

I wil change the values to the names of the car. This will make life easier I think.
I know that if the user clicks submit it should be processed through my php script and then send on to my mailbox. But how do I get the script to process the selection. I don't know how to implement it in the form.

As I said I am new to php so I might be asking a dumb question here but I am learning :lol: .
TheBentinel.com
Forum Contributor
Posts: 282
Joined: Wed Mar 10, 2004 1:52 pm
Location: Columbus, Ohio

Post by TheBentinel.com »

Use another one of these lines:
$voorletter = $_POST['voorletter'];

But grab the value of your select:
$lijst = $_POST['lijst'];
Flutje
Forum Newbie
Posts: 3
Joined: Tue Apr 13, 2004 6:03 am

Post by Flutje »

Thank you so much. I never knew it would be that simple. Life can be weird sometimes. I tried all sorts of methods except the most obvious one 8O

Thanks for helping me out here!!!

Martin
Post Reply