My select options won't post to E-mail please help

ok so here is the html form

[code]
Name:




E-Mail:




Contact Number:



What type of website?

Simple brochure website ecommerce/shopping website CMS website other

How many pages?

1 2-5 5-10 10-20 20+

Brief description of your project





[/code]

here the php

[php]<?php

$emailSubject = ‘quoteformprocess!’;
$webMaster = ‘[email protected]’;

$name = $_POST[‘name’];
$email = $_POST[‘email’];
$number = $_POST[‘number’];
$websitetype = array(1 => “brochure”, 2 => “ecommerce”, 3=>“cms”, 4=>“other”);
$websitetype = $websitetype[(int) $_POST[‘websitetype’]];
$webpages = array(1 => “1”, 2 => “2-5”, 3=>“5-10”, 4=>“10-20”, 5=>“20+”);
$webpages = $webpages[(int) $_POST[‘webpages’]];

$body = <<<EOD




Name: $name

Email: $email

Number: $number

Websitetype: $websitetype

Webpages: $webpages

EOD;
$headers = “From: $email\r\n”;
$headers .= “Content-type: text/html\r\n”;
$success = mail($webMaster, $emailSubject, $body,
$headers);

/* Results rendered as HTML */
$theResults = <<<EOD

sent message
Put your message in here letting the sender know the message has been successfully sent
EOD; echo "$theResults"; ?>[/php]

the fields post fine but the selection is blank…all help is appreciated thank you

For reading a drop-down, you use this format: $_POST[‘SELECT-NAME’]… The value is retrieved form the "VALUE"s in the OPTIONS … So…
This:
[php]
$websitetype = $websitetype[(int) $_POST[‘websitetype’]];
[/php]

Should be:
[php]
$websitetype = $_POST[‘websitetype’];
[/php]
Nothing else… INT’s do NOT matter as PHP does not care and you already set them to INT in the OPTION value=‘1’, etc… (Actually, you set them to a string “1”, depends if you need the number, if you do, change your options to be VALUE=1, NOT VALUE=“1”…)

Now for the webpages…
This:
[php]
$webpages = array(1 => “1”, 2 => “2-5”, 3=>“5-10”, 4=>“10-20”, 5=>“20+”);
$webpages = $webpages[(int) $_POST[‘webpages’]];
[/php]

Should be:
[php]
$webpagesText = array(“1”, “2-5”, “5-10”, “10-20”, “20+”);
$webpages = $webpages($_POST[‘webpages’]);
[/php]
So, this will pull a text value from this array based on the number selected from the form…
You then, can put that text into the email… Unless I missed some reason why you would want all these arrays and not simple code…

Try it and let us know if it does not work for you…

Sponsor our Newsletter | Privacy Policy | Terms of Service