Jump to content

How to prevent direct accessing a particular page?


don11

Recommended Posts

If you want users just to click on a link on index page to access the sign up page you can simply do this:

 

Add a link to the index page. The link should be:  http://www.mysite.com/page1/page2/signup.php?do=activate

Then add this to the top of the sign up page:

if(!isset($_GET['do']))

{

//Redirect to index page

}

else

{

//show contents of page

 

}

Link to comment
Share on other sites

header("Location: ../index.php");exit; 

Above code is redirecting even from index page.

 

Add a link to the index page. The link should be:  http://www.mysite.com/page1/page2/signup.php?do=activate


Then add this to the top of the sign up page: 
if(!isset($_GET['do']))
{
header("Location: ../index.php");
}
else
{
//show contents of page

}

This code is also redirecting even from index page.

 

Link to comment
Share on other sites

just an idea...

 

index page

start sessions

create var1 random number 1

store var1 in sessions

create link using ?myvar=var1

 

2nd page

start sessioins

check to see if session var AND get var (1) are both set (2) both integers (3) equal each other -

if not redirect

else display page

Link to comment
Share on other sites

header("Location: ../index.php");exit; 

Above code is redirecting even from index page.

 

Add a link to the index page. The link should be:  http://www.mysite.com/page1/page2/signup.php?do=activate



Then add this to the top of the sign up page: 
if(!isset($_GET['do']))
{
header("Location: ../index.php");
}
else
{
//show contents of page

}

This code is also redirecting even from index page.

 

The code should work. It is pretty simple and clear. May be there is any typo while you wrote the code. Just check it once again. :-)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.