For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > April 2005 > hide page and re-direct









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author hide page and re-direct
Brian

2005-04-13, 8:55 pm

Hi

This may not be the best group to post this on but I could not
find newsgroup that is about site design.

I have been asked to put a small site together, on the front
page there will be a log in, the user details are to be held in
a MySQL database which will be accessed by PHP.
If a successful login then the user will be re-directed to 1
of X pages depending on their user account.

The problem is the X pages the client wants them in as
a static page and not done on the fly. I could do a page
with a re-direct in it if they have not logged in, what my
worry is, is 1) these pages may get index by a search engine
and 2) if they are the page would come up and is a user
is quick enough they could click stop before they get re-directed
and see the page.

Is there anyway to hide all the pages content if not logged in even if
a user does view source and then re-direct them back to the home page
but still have a static page that my client can alter?

Thanks in advance

Brian



Chris B

2005-04-13, 8:55 pm

Brian wrote:
> Hi
>
> This may not be the best group to post this on but I could not
> find newsgroup that is about site design.
>
> I have been asked to put a small site together, on the front
> page there will be a log in, the user details are to be held in
> a MySQL database which will be accessed by PHP.
> If a successful login then the user will be re-directed to 1
> of X pages depending on their user account.
>
> The problem is the X pages the client wants them in as
> a static page and not done on the fly. I could do a page
> with a re-direct in it if they have not logged in, what my
> worry is, is 1) these pages may get index by a search engine
> and 2) if they are the page would come up and is a user
> is quick enough they could click stop before they get re-directed
> and see the page.
>
> Is there anyway to hide all the pages content if not logged in even if
> a user does view source and then re-direct them back to the home page
> but still have a static page that my client can alter?
>
> Thanks in advance
>
> Brian
>
>
>


I don't know an exact answer, but if there isn't one you can..

to keep the robots away <meta name="robots" content="noindex,nofollow">
in the <head>

compress the code onto one line.. i.e. <html><head><meta ...></head>
etc. It's still readable but not as easy. Throw some random gibberish in
there too e.g. /*jfkdsjfdsj*/ if you like.
It's not especially clean but it'd make the code hard to read.
Kimmo Laine

2005-04-13, 8:55 pm

"Brian" <not@given.com> kirjoitti
viestissä:3%e7e.21223$il.10391@newsfe5-win.ntli.net...
> Hi
>
> This may not be the best group to post this on but I could not
> find newsgroup that is about site design.
>
> I have been asked to put a small site together, on the front
> page there will be a log in, the user details are to be held in
> a MySQL database which will be accessed by PHP.
> If a successful login then the user will be re-directed to 1
> of X pages depending on their user account.
>
> The problem is the X pages the client wants them in as
> a static page and not done on the fly. I could do a page
> with a re-direct in it if they have not logged in, what my
> worry is, is 1) these pages may get index by a search engine
> and 2) if they are the page would come up and is a user
> is quick enough they could click stop before they get re-directed
> and see the page.
>
> Is there anyway to hide all the pages content if not logged in even if
> a user does view source and then re-direct them back to the home page
> but still have a static page that my client can alter?


Would it be possible to call the pages like
gatekeeper.php?p=some_static_page.html
where gatekeeper.php would simply be
<?php
if(/* logged in, insert code */){
$page = "my_secret_directory/".$_REQUEST['p'];
if(file_exists($page))
readfile($page);
else header("HTTP/1.0 404 Not Found");
}
?>
and protect my_secret_directory from public access. Perhaps with
mod_rewrite, the "pagenames" could be transleted into
gatekeeper.php?p="pagename", so nothing would change with the static pages
even.


Geoff Berrow

2005-04-13, 8:55 pm

I noticed that Message-ID: <3%e7e.21223$il.10391@newsfe5-win.ntli.net>
from Brian contained the following:

>The problem is the X pages the client wants them in as
>a static page and not done on the fly. I could do a page
>with a re-direct in it if they have not logged in, what my
>worry is, is 1) these pages may get index by a search engine
>and 2) if they are the page would come up and is a user
>is quick enough they could click stop before they get re-directed
>and see the page.


Use sessions. Set a session variable on the login page and check for
it(or them) on the protected page. If the session variable is not
present, redirect to the login page.

--
Geoff Berrow 0110001001101100010000000110
0011011010110110010001101111011001110010
11
1001100011011011110010111001110101011010
11
Brian

2005-04-19, 3:56 pm

Thanks Kimmo

Your idea worked out best, I am hold the templates in a
htaccess directory and after the login has been done read
the template in

Many thanks

Brian



<?php
> if(/* logged in, insert code */){
> $page = "my_secret_directory/".$_REQUEST['p'];
> if(file_exists($page))
> readfile($page);
> else header("HTTP/1.0 404 Not Found");
> }
> ?>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com