finding problem here header or isset

Alles, was PHP betrifft, kann hier besprochen werden.

finding problem here header or isset

Postby sandeep.2405 » 06. January 2011 13:01

I am using the following code. The form has an optio to select the level. If he selects 1 he is to be diverted to page1.php, else to page2.php. But when I had uploaded the file in my local XAMPP server as well in the web server, it does not work. I had been trying it for many days but in vain. Can any one please tell me what is wrong.

if ($actionflag=="manager" && isset($actionflag) )
if (empty ($form[level] ) )
$message .= "Please identify yourself <br>\n";
if ( $message == "") // we found no errors
cleanMemberSession ($id, "", "", $form[statename], "", $form[level] );
if($form[level] == "DC")
header ( "Location: page1.php?".SID);
header ( "Location: page2.php?".SID);
Posts: 1
Joined: 06. January 2011 12:48

Re: finding problem here header or isset

Postby Nobbie » 06. January 2011 15:30

>header ( "Location: page1.php?".SID)

This is bad programming style. On one hand, the syntax is wrong (even if it works), because the "Location:" Tag expects a fully(!) qualified URL (not only a file name) and on the other hand, why do you use this cludgy header()-function instead of simply including the desired file "page1.php"? Including the file will also have the big advantage that all variables are within the scope of the included files (and aren't lost due to the redirection).

I know, there are many scripts out there which use header-redirection on local files, but this does NOT mean, that is "good programming style". It's simply bad and may be one reason for your problems.
Posts: 10602
Joined: 09. March 2008 13:04

Return to PHP

Who is online

Users browsing this forum: No registered users and 19 guests