0

Hello. I am currently working on a website to post some articles I write for my friends. The problem I am currently having is with a dynamic redirect. I have a dropdown list that is populated dynamically from a mysql database. That part is working fine but I can't get the redirect to include the id number of the selected item in the dropdown list. I want to redirect the user to another file on the same site where the ?id= the id of the selected month. If I change both instances of post in the below code to get and click go it shows the correct id number in the address bar but does not redirect. Keeping the below code as is causes it to redirect but the id number is blank so no page shows up. Any help you can provide would be appreciated.

echo '</td><form action="httest.php" method="post"><td>
<SELECT NAME=months> 
<OPTION VALUE=0>Choose Month</option>='.$months.' 
</SELECT><input type="submit" name="month" value="Go"></td></form>';

if (isset($_POST['month'])){
$pid = $_post['months'];
header("HTTP/1.1 301 Moved Permanently"); 
header("Location: arttest.php?id=$pid"); 
exit(); 
}

Edited by eagled2: n/a

3
Contributors
4
Replies
7
Views
7 Years
Discussion Span
Last Post by MooGeek
0

when using header, it should be on the top. always. instead, try this one

if (isset($_POST['month'])){
$pid = $_post['months'];
header("HTTP/1.1 301 Moved Permanently"); 
header("Location: arttest.php?id=$pid"); 
exit(); 
}
echo '</td><form action="httest.php" method="post"><td>
<SELECT NAME=months> 
<OPTION VALUE=0>Choose Month</option>='.$months.' 
</SELECT><input type="submit" name="month" value="Go"></td></form>';

if still doesn't work you should try using HTMLs Redirect

<meta http-equiv="REFRESH" content="0;url=http://www.the-domain-you-want-to-redirect-to.com"></HEAD>

or maybe use javascript? http://www.tizag.com/javascriptT/javascriptredirect.php


Goodluck :D

0

Thanks. I switched like you said but it still wasn't working. I forgot about the case in POST. Once I capitalized it the button was working properly.

0

For Dynamic Redict Use this....It may help you a lot.

function redirecturl($url)
{
echo '<script type="text/javascript">';
echo "window.location='$url';";
echo '</script>';
}

Thanks,
Karthik,

Edited by Ezzaral: Snipped &quot;fake sig&quot; link. Please restrict such links to your site-wide user signature, which can be edited from the user control panel.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.