468,321 Members | 1,848 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,321 developers. It's quick & easy.

To redirect if no parameters

Hi at all
I have a php page where I display mysql table datas
if the user call the page without one or more parameters I'ld want to
redirect it to another page
Therefore I wrote
if ($REQUEST_METHOD=="POST") {
$HTTP_STR=$HTTP_POST_VARS;
}else{
$HTTP_STR=$HTTP_GET_VARS;
}
while(list($chiave,$valore)=each($HTTP_STR))
{
}
if ($dbf=="")
{header("Location: http://www.pippo.es/");exit()}
But it do not work
Why please?
regards
May 19 '07 #1
2 1729
Robertu kirjoitti:
$HTTP_STR=$HTTP_POST_VARS;
$HTTP_STR=$HTTP_GET_VARS;
$HTTP_POST_VARS and $HTTP_GET_VARS are deprecated. It means do not use
these anymore. These will not be avaialable in future versions of php,
instead use $_POST and $_GET.
if ($dbf=="")
{header("Location: http://www.pippo.es/");exit()} <<--- missing semicolon ; after exit().
Try not to write everything on one line so you'll see better what is
wrong. It's easier to read.

if ($dbf=="") {
header("Location: http://www.pippo.es/");
exit();
}

--
Ra*********@gmail.com

"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
May 19 '07 #2
At Sat, 19 May 2007 07:02:15 +0000, Robertu let his monkeys type:
Hi at all
I have a php page where I display mysql table datas
if the user call the page without one or more parameters I'ld want to
redirect it to another page
Therefore I wrote
if ($REQUEST_METHOD=="POST") {
$HTTP_STR=$HTTP_POST_VARS;
}else{
$HTTP_STR=$HTTP_GET_VARS;
}
while(list($chiave,$valore)=each($HTTP_STR))
{
}
if ($dbf=="")
{header("Location: http://www.pippo.es/");exit()}
But it do not work
Why please?
regards
In your posted code the while loop does nothing, and I wonder where $dbf
gets its value. Just a typo here or actual code?

Or have you -by chance- sent any output to the browser on this page
BEFORE sending the location header? (You should not, as it forces a header
to be sent already).

Also, $HTTP_POST_VARS, $HTTP_GET_VARS and $REQUEST_METHOD are deprecated,
use $_POST, $_GET and $_SERVER['REQUEST_METHOD'] instead.

HTH
Sh.
May 19 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by J. Miller | last post: by
3 posts views Thread by JohnZing | last post: by
3 posts views Thread by neil_pat | last post: by
3 posts views Thread by Peter Kirk | last post: by
3 posts views Thread by alasdair.stirling | last post: by
5 posts views Thread by Nirmal Singh | last post: by
3 posts views Thread by =?Utf-8?B?UGF0UA==?= | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by howard w | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.