Jump to content

PHP Pop-Up Form Submission


jrapin

Recommended Posts

I'm attempting to program a form with a pop-up menu to submit the choices a user makes.
Previously the form was using the checkboxes effectively (Thanks to Orio), but I wanted to condense the information a little more. Right now the code uses this as this array method:

$checkboxes = array("apples", "oranges", "grapes", "pears");
foreach ($checkboxes as $checkbox){
if(isset($_POST[$checkbox]))
echo $checkbox." is requested, ";
}
mail("[email protected]","Dinner Reservations",$message,$headers);

How can I program it so that it submits the pop-up selections instead?

[attachment deleted by admin]
Link to comment
https://forums.phpfreaks.com/topic/27584-php-pop-up-form-submission/
Share on other sites

Well in order to send the results to an e-mail address you will have to make this a form and submit it. Once it is submitted you can pull the values and put them into a properly formatted e-mail.

first you need to add a submit button.
then you need to change your fruit lines
they should be
[code] <p>Name of Fruit:
<select name="fruit">
<option value="Apples">Apples</option>
<option value="Oranges">Oranges</option>
<option value="Grapes">Grapes</option>
<option value="Pears">Pears</option>
</select>
<select name="amount">
<option vlue="1">One</option>
<option vlue="2">Two</option>
<option vlue="3">Three</option>
<option vlue="4">Four</option>
<option vlue="5">Five</option>
</select>[/code]

Then you just call them in the e-mail part.
[code] $headers  = "From:".$_POST['email_address']."\r\n";
$headers .= "Content-Type: text/plain;\r\n charset=iso-8859-1\r\n";
$message  = "Name: " . $_POST['first'] . " " . $_POST['last'] . "\r\n";
$message .= "Email: " . $_POST['email_address'] . "\r\n";
$message .= "Phone: " . $_POST['phone'] . "\r\n";
$message .= "Organization: " . $_POST['organization'] . "\r\n";
$message .= $_POST['message_body']."\r\n";
        $message .= "You have selected ".$_POST['amount']." ".$_POST['fruit']." as your fruit choice\r\n";
[/code]
Or however you want to get them.

I keep getting an error in your script about the message body. Where is this coming from??

Ray

I'm not concerned about the body error message - the code is fully functional.
I need some additional help - to make the menu more interactive. I was thinking of the else coommand or else if.

What I ned it to do is this:
for each catagory, a complimentary menu will adjust to that particular item. For example, If the user chooses Apples, they can pick an amount of one to five. If the user chooses oranges, they choose between six and ten and if they pick grapes they will have the option on selecting eleven to fifteen.

How can this be done?
So you want two drop down selection boxes in a form, the second of which populates dependant on the value selected in the first box.  Is this right?

If you want to do it with PHP, I think you will want to reload the page on selection in the first box.  A script on the page can check if a value has been selected in the first box, if it has then query a database table that contains the values for the second box that relates to the first selection.

I think you can probably also do the same without reloading the page using either Java Script of CSS, not sure about those methods though?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.