Solved

PHP Code Submit Button

Posted on 2011-03-07
2
348 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

911 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now