Solved

PHP Code Submit Button

Posted on 2011-03-07
2
352 Views
Last Modified: 2012-05-11
In the below code, I need to be able to choose an office from teh drop down box then click the submit button. If I choose "Office A" then click the "Submit button, I need to be redirected to http://mysite/query/officea.php

If I choose "Office B" from the drop down list, I need to be redirected to http://mysite/query/officeb.php

Is this possible?
<body>

	<h1>Please choose an office</h1>
	<br>
		
	<b>Choose an Office: </b><br />   
<select name="office" /> <br />
<option value=""></option> 
<option value="Office A">Office A</option> 
<option value="Office B">Office B</option> 

</select>
<input type="submit" value="Submit" />
</br>
		
</body>

Open in new window

0
Comment
Question by:wantabe2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
enachemc earned 250 total points
ID: 35056817
<body>

      <h1>Please choose an office</h1>
      <br>
            
      <b>Choose an Office: </b><br />  
      <form action="a.html" >
<select name="office" onChange="this.form.action=this.value+'.php'"/> <br />
<option value=""></option>
<option value="OfficeA">Office A</option>
<option value="OfficeB">Office B</option>

</select>
<input type="submit" value="Submit" />
</form>
</br>
            
</body>
0
 
LVL 2

Assisted Solution

by:adeelshahid
adeelshahid earned 250 total points
ID: 35056888
try this.

if (isset($_POST['office'])) {
            switch ($_POST['office'])
            {
                  case 'Office A':
                        header('Location: http://mysite/query/officea.php');
                        die();
                  
                  case 'Office B':
                        header('Location: http://mysite/query/officeb.php');
                        break;
            }
      }
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question