Jump to content

Php Header


nielcleo
 Share

Recommended Posts

Using a location header will cause the browser to redirect, and it will show the new URL. You should capitalize Location, and put a space after the colon. It will give an error like it isn't redirecting properly if you have a loop, where the page keeps redirecting to itself.

Link to comment
Share on other sites

it still error and i got error because its redirecting on the page its self..im checking my index.php if the session still available it will redirect on the members page.. which has a link..index.php?p=members..any tricks that you can suggest that will not show the original php that having a content of the members page..

Link to comment
Share on other sites

Show us the code you have now currently

Edited by birbal
Link to comment
Share on other sites

here's my index.php

<?phpsession_start();if(session_is_registered(myusername)){header("LOCATION: index.php?p=success");}?> <html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><title>New Page 1</title><script type="text/javascript" language="javascript" src="ceres.js"></script></head><body><a href="?p=page1">page1</a> | <a href="?p=page2">page2</a> | <a href="?p=page3">page3</a><br><table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"><tr><form name="login" method="post" action="checklogin.php"><td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"><tr><td colspan="3"><strong>Member Login </strong></td></tr><tr><td width="78">Username</td><td width="6">:</td><td width="294"><input name="myusername" type="text" id="myusername"></td></tr><tr><td>Password</td><td>:</td><td><input name="mypassword" type="text" id="mypassword" ></td></tr><tr><td> </td><td> </td><td><input type="submit" name="Submit" value="Login"></td></tr></table></td></form></tr></table><div id="main_div"></div></body></html><?$x=isset($_GET['p'])?$_GET['p']:"";switch($x){case"page1":include("page1.php");break;case"page2":include("page2.php");break;case"page3":include("page3.php");break;case"check":include("checklogin.php");break;case"success":include("main.php");break;default:echo"Nopage is selected Yet";}?>

Link to comment
Share on other sites

Session_is_registered() is deprecated. Use $_SESSION super global array and check with isset() that any particuler data exist or not. It is not the solution of ur problem but it will be best.For the problem. .what does main.php holds? Is there any redirecti0n?

Link to comment
Share on other sites

Session_is_registered() is deprecated. Use $_SESSION super global array and check with isset() that any particuler data exist or not. It is not the solution of ur problem but it will be best.For the problem. .what does main.php holds? Is there any redirecti0n?
main.php..only holds a members content
Link to comment
Share on other sites

Your if statement also needs to check $_GET['p']. If you just redirected you don't want to redirect again. That's where the infinite loop is happening, you always redirect if the session is active. You need to check more than only if the session is active, you also need to check if you've already redirected.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...