Solved

PHP Code Submit Button

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
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 videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

617 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