passing data from echo drop down list to another page

hi expert,

I am new in php, I would like a question regarding to passing data from echo drop down list to another page.
for example, I am doing echo a drop down list in php and how I able to pass the selected option value to another page. normally , when I am using name of drop down list as a linkage to get the value.<?php <select name='option' id='option' > ? > .
LVL 2
rolandmyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

InsoftserviceCommented:
I would suggest to read some documents from w3schools and some blogs for PHP it would be more beneficial for you.
Please check the below code which would help you to pass data from one page to other by using post method
<form action="http://mydomain.com/page.php" method="post"> <br />
    <select> name="website_string" 
        <option value="" selected="selected"></option>
    <option VALUE="abc"> ABC</option>
    <option VALUE="def"> def</option>
        <option VALUE="hij"> hij/option>   
    </select>
    <input type="submit" name="website_string"  >
</form>

Open in new window

0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Your php renders the html.  Assuming you can get rendered output like below.  (Note the code from insoftservice above is a bit off on the closing tag for the select tag)

<select name="option" id="option">
     <option value="123">item 123</option>
     <option value="124">item 124</option>
     <option value="124">item 124</option>
</select>

Open in new window


To get this to another page you can use a form or ajax.  Using a form you can send a post or a get.

<form method="post" action="somepage.php">
     <select name="option" id="option">
          <option value="123">item 123</option>
          <option value="124">item 124</option>
          <option value="124">item 124</option>
    </select>
    <button type="submit">Submit</button>
</form>

Open in new window

In the above sample you are sending a post and therefor can capture the data using $_POST["variable"]
$selected_item = $_POST["option"]

Open in new window

<form method="get" action="somepage.php">
     <select name="option" id="option">
          <option value="123">item 123</option>
          <option value="124">item 124</option>
          <option value="124">item 124</option>
    </select>
    <button type="submit">Submit</button>
</form>

Open in new window

In the above sample you are sending a get an and therefor can capture the data using $_GET["variable"].   The get will send the form data to the url.
$selected_item = $_GET["option"]

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.