Contact form/Jump Menu help needed urgently
Posted: Tue Aug 18, 2009 11:15 am
Hi there,
Im very new to php. Im doing a query form for a site but have problems getting the selected data from a jump menu to send through to an email correctly.
The information posts, but its incorrect.
Here is the code for the jump menu :
<?php
$province = array (1 => 'Western Cape',
'West Coast', 'Cape Overberg', 'Northern Cape', 'Eastern Cape',
'Free State', 'Limpopo', 'Gauteng');
echo '<select name="province">';
foreach ($province as $key => $value)
{
echo "<option value=\"$key\">$value</option>\n";
}
echo "</select>";
?>
Heres the code that is meant to get the info :
$province_select=' ';
for ($i=0; $i < count($province); $i++)
{
$province_select=$province[$i];
}
Lastly to print out the array I do the following :
$array = array ($name, $surname, $contact, $email_confirmed, $province_select, $date);
$fields = array ('First Name', 'Surname', 'Contact Number', 'Email Address', 'Province', 'Region/Town', 'Date of Function');
echo 'Thank you for your Enquiry. <br><br>You Entered the following details : <br>';
for ($i=0; $i < count($array); $i++)
{
$array [$i] = ucfirst($array [$i]);
echo '<table width="300px"><tr><td bgcolor="#669933" width="65%">' . $fields [$i] . ' : </td><td bgcolor="#669933">' . $array [$i] . '</td></tr></table>';
}
When I echo out $province_select [$i] it always prints out 'Limpopo', which is the 7th item in the array, instead of the selected option.
Please advise on where I have coded incorrectly?
Thanks in advance.
Im very new to php. Im doing a query form for a site but have problems getting the selected data from a jump menu to send through to an email correctly.
The information posts, but its incorrect.
Here is the code for the jump menu :
<?php
$province = array (1 => 'Western Cape',
'West Coast', 'Cape Overberg', 'Northern Cape', 'Eastern Cape',
'Free State', 'Limpopo', 'Gauteng');
echo '<select name="province">';
foreach ($province as $key => $value)
{
echo "<option value=\"$key\">$value</option>\n";
}
echo "</select>";
?>
Heres the code that is meant to get the info :
$province_select=' ';
for ($i=0; $i < count($province); $i++)
{
$province_select=$province[$i];
}
Lastly to print out the array I do the following :
$array = array ($name, $surname, $contact, $email_confirmed, $province_select, $date);
$fields = array ('First Name', 'Surname', 'Contact Number', 'Email Address', 'Province', 'Region/Town', 'Date of Function');
echo 'Thank you for your Enquiry. <br><br>You Entered the following details : <br>';
for ($i=0; $i < count($array); $i++)
{
$array [$i] = ucfirst($array [$i]);
echo '<table width="300px"><tr><td bgcolor="#669933" width="65%">' . $fields [$i] . ' : </td><td bgcolor="#669933">' . $array [$i] . '</td></tr></table>';
}
When I echo out $province_select [$i] it always prints out 'Limpopo', which is the 7th item in the array, instead of the selected option.
Please advise on where I have coded incorrectly?
Thanks in advance.