Jump to content

Mode from drop-down-list


ecopetition

Recommended Posts

Hi guys.

 

I made a drop down list similar to:

 

<form action="action.php" method="post">

<select name="mode">

<option value="option1">Option 1</option>

<option value="option2">Option 2</option>

<option value="option3">Option 2</option>

<input type="submit" name="submit" value="Submit" />

</select>

</form>

 

What PHP should be contained in the form action to return the option value when that option is selected?

 

I know this is probably very simple but I have searched Google and found nothing on it.

 

Thanks a lot,

Ecopetition

Link to comment
Share on other sites

bro,

 

your form action is action.php yet your method is equal to post...

if your gonna be using the $_POST method of retrieving data than your form's action should be $_SERVER['PHP_SELF'] otherwise if you are using the get method than the form should be set to: <form name="formname" action="action.php" method="get">

if it is the get method ur gonna be using:

the action.php should like

<?php
//action .php
$mode = $_GET['mode'];
echo $mode;
?>

 

HoTDaWg

Link to comment
Share on other sites

 

 

if your gonna be using the $_POST method of retrieving data than your form's action should be $_SERVER['PHP_SELF'] otherwise if you are using the get method than the form should be set to: <form name="formname" action="action.php" method="get">

 

that completely wrong. the action attribute of the form does NOT have to be set to current page for it to be POST... in fact, i'd recommend using POST for 99.9% of the forms you create

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.