Subject: [thelist] having problems with php redirect form

mary diamond mdiamond at mum.edu
Fri Sep 20 09:22:01 CDT 2002


--
[ Picked text/plain from multipart/alternative ]
----- Original Message -----
Message: 38
Date: Fri, 20 Sep 2002 01:40:20 -0400
From: "Timothy J. Luoma" <lists at tntluoma.com>
To: thelist at lists.evolt.org
Subject: [thelist] having problems with php redirect form
Reply-To: thelist at lists.evolt.org


I have a form at http://tntluoma.com/form.html

which is supposed to be a drop down menu for navigation.  Here's an
abbreviated version of what it says:

<form action="/redirect.php">
<select id="goto" name="goto">
<option value="" selected="selected">Jump To Day</option>
<option value="/opera/lover/day01-why/">Day 1: Why</option>
<option value="/opera/lover/day02-install/">Day 2: Install</option>
<option value="/opera/lover/day03-interface/">Day 3: Interface</option>
<input type="submit" value="go" />
</form>
>and here is the 'redirect.php'

<?php
$TARGET = $_SERVER["QUERY_STRING"];

header("Location: $TARGET");

exit();
?>

>but this isn't coming close to working.
#___________________________________________

I guess you're assuming GET is the default method so '?value=$value' should append to the url on form submission. Does it?
(It helps to know what happens when you submit your form, as 'doesn't work, is pretty broad.)

alternatives:
you could use METHOD="POST"  in your form, and use $_POST['values'] for the value you assign to $TARGET on redirect.php

or, if you might POST and append the selected value to the url you can do it with
<form method="post" action="/redirect.php?value=<?=$value?>">
and you will prolly need to rawurlencode($value) since it has slashes & stuff in it:
<form method="post" action="/redirect.php?value=<?=rawurlencode($value) ?>">

if $_SERVER["QUERY_STRING"] still doesn't pick it up, try using $_GET['values']  for the value you assign to $TARGET on redirect.php. (echo it to the page to see if you need to rawurldecode() it.)

sorry, I don't have much experience with $_SERVER["QUERY_STRING"]
but you could do something to help you debug, like:


<?
if (!empty($_SERVER['QUERY_STRING']){
    $TARGET = $_SERVER["QUERY_STRING"];
    header("Location: $TARGET");
    exit();

}else{

    echo \$_SERVER['QUERY_STRING'] was empty<BR>\n";
}
?>


HTH
Mary Diamond

--




More information about the thelist mailing list