Solved

PHP Code Submit Button

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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

773 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