View Full Version : PHP - passing values
thebloodpoolkid
November 18th, 2004, 05:03 PM
I have a form built in HTML. The form has 3 DropDown/List Menu's. In additon it has standard input fields. The form simple gathers the vaules (POST) to a page which processes the script. The values are then formatted and sent to an email address. I am able to get the input fields to function properly. Those values do show up as enetered by the end user. I am not able to get the current selected value in the dropdown menu to send.
The question. How do I get PHP to grab the current value from the menu and submit it to the email addy.
I have searched this. Was unable to find an exact method.
ironikart
November 18th, 2004, 06:41 PM
Drop down menus should be accessible exactly the same as normal input fields. If it is a multiple select menu then you have to use the square brackets so the form submits an array.
<select name="list[]" multiple></select>
Say if it had 5 options, it would return the array:
$_POST['list'][0]
$_POST['list'][1]
$_POST['list'][2]
$_POST['list'][3]
$_POST['list'][4]
thebloodpoolkid
November 18th, 2004, 07:26 PM
Below is the entire script.
The following are the names of the menus and the assigned varibles.
$selectedBenefit = $_POST['selectedBenefit'];
$preferredtMethod = $_POST['preferredtMethod'];
$contactTime = $_POST['contactTime'];
<?php
$selectedBenefit = $_POST['selectedBenefit'];
$preferredtMethod = $_POST['preferredtMethod'];
$contactTime = $_POST['contactTime'];
$firstName=$_POST['firstName'];
$lastName=$_POST['lastName'];
$Spouse=$_POST['Spouse'];
$addressLine1=$_POST['addressLine1'];
$addressLine2=$_POST['addressLine2'];
$City=$_POST['City'];
$zipCode=$_POST['zipCode'];
$homePhone=$_POST['homePhone'];
$workPhone=$_POST['workPhone'];
$cellPhone=$_POST['cellPhone'];
$Email=$_POST['Email'];
$Comments=$_POST['Comments'];
$dataSent .= "selectedBenefit: " . $selectedBenefit . "\n";
$dataSent .= "preferredtMethod: " . $preferredtMethod . "\n";
$dataSent .= "contactTime: " . $contactTime . "\n";
$dataSent = "FirstName: " . $firstName . "\n";
$dataSent = "LastName: " . $lastName . "\n";
$dataSent .= "Spouse: " . $Spouse . "\n";
$dataSent .= "Addressline1: " . $addressLine1 . "\n";
$dataSent .= "Addressline2: " . $addressLine2 . "\n";
$dataSent .= "City: " . $City . "\n";
$dataSent .= "zipCode: " . $zipCode . "\n";
$dataSent .= "HomePhone: " . $homePhone . "\n";
$dataSent .= "WorkPhone: " . $workPhone . "\n";
$dataSent .= "CellPhone: " . $cellPhone . "\n";
$dataSent .= "Email: " . $Email . "\n";
$dataSent .= "Comments: " . $Comments;
mail( "webmaster@halloweeneve.com", "Employee Home Loan form", $dataSent, "From: $lastName" ) or die("There was a problem sending the email. Please contact the system administrator");
header( "Location: http://www.halloweeneve.com/ehl/confirmation.php" );
?>
Thanks for the reply
ironikart
November 18th, 2004, 08:51 PM
If it's just a normal drop down select menu then just check that your spelling in the php variable is the same as the name value on the select box... You're not doing anything wrong with the accessing of the variables unless its a multiple select.
thebloodpoolkid
November 19th, 2004, 10:42 AM
I found the issue. In the following code evertything before FirstName was being ignored. FirstName was the initialization of the Varible of $dataSent
$dataSent .= "selectedBenefit: " . $selectedBenefit . "\n";
$dataSent .= "preferredtMethod: " . $preferredtMethod . "\n";
$dataSent .= "contactTime: " . $contactTime . "\n";
$dataSent = "FirstName: " . $firstName . "\n";
$dataSent = "LastName: " . $lastName . "\n";
Thanks for the help.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.