nielcleo Posted December 15, 2011 Share Posted December 15, 2011 hii would like to ask if it is possible to use index.php?p=page1 header("location:index.php?p=page1"); when i use that in header it sends me The page isn't redirecting properlywhat is the rightway to redirect me in a page without displaying the original php file in the adress bar.. Link to comment Share on other sites More sharing options...
justsomeguy Posted December 15, 2011 Share Posted December 15, 2011 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 More sharing options...
nielcleo Posted December 16, 2011 Author Share Posted December 16, 2011 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 More sharing options...
birbal Posted December 16, 2011 Share Posted December 16, 2011 Show us the code you have now currently Link to comment Share on other sites More sharing options...
nielcleo Posted December 16, 2011 Author Share Posted December 16, 2011 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 More sharing options...
birbal Posted December 16, 2011 Share Posted December 16, 2011 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 More sharing options...
nielcleo Posted December 16, 2011 Author Share Posted December 16, 2011 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 More sharing options...
justsomeguy Posted December 16, 2011 Share Posted December 16, 2011 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.