Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Simple form and PHP to redirect user to a new webpage on form postback
if(isset($_POST['submit'])) {
$loc = "Location: " . $_POST['newPage'];
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
Going To A New URL Via A Drop-Down List: JavaScript And DOM, PHP, ASP.NET
Copyright 2007 Doug Vanderweide
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <>.
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Going To A New URL Via A Drop-Down List: JavaScript And DOM, PHP, ASP.NET Example 1: Via JavaScript / DOM</title>
<link href="../demo.css" rel="stylesheet" type="text/css" />
Going To A New URL Via A Drop-Down List:<br />
JavaScript And DOM, PHP, ASP.NET<br />
Example 2: Via PHP
<form id="jumpForm" method="post" action="<? echo $_SERVER['PHP_SELF']; ?>">
<label>Select A Page:&nbsp;
<select id="newPage" name="newPage">
<option value="index.html" selected="selected">This page</option>
<option value="test.html">Another page, this directory</option>
<option value="../js_ddl_iframe/index.html">Another page, another directory, relative address</option>
<option value="">Another page, another directory, absolute address</option>
<option value="">Another domain</option>
<input type="submit" name="submit" id="submit" value="Go!" />
<p>Selecting a location above and clicking on the Go! button will take you to another page. Use your browser's Back button to return here.</p>
<p><a href="index.html">Example 1: Via JavaScript / DOM</a></p>
<p><a href="">Going To A New URL Via A Drop-Down List: JavaScript And DOM, PHP, ASP.NET</a></p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.