Jump to content


Password Protected Page


2 replies to this topic

#1 FK69

    Young Padawan

  • Members
  • Pip
  • 57 posts
  • Location:Melbourne, Australia

Posted 29 July 2005 - 11:29 PM

I got a news system but any1 can post in it atm i got the news dir password protected but that means you have to enter the username and password to even look at the news and i cant be arsed moving the display.php out of the dir into the main folder so i wanted to find a code that i can protect certain files/pages with like post.php edit.php and delete.php.

can ne1 help find a code or a tut for this i looked but i didnt find it maybe i wasnt looking hard enough.

#2 MillerTime

    Young Padawan

  • Members
  • Pip
  • 69 posts

Posted 30 July 2005 - 01:43 PM

add this line on the page where you write the news:

password: <input type="password" name="pass"><br>

then add this line at the top of the php page that adds the news:
if($_POST['pass'] != "Your password here"){
echo '<meta http-equiv="refresh" content="3; URL=../index.php">';
die("Password is invalid. Redirecting back to index.php");
}

That should work. It would be helpful if you posted the actual code tho

#3 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 30 July 2005 - 04:42 PM

It would actually be easier to use http authentification. That way you don't have to login constantly. Just do a tutorial search for it, and you should find loads of tutorials on how to do it.
You can also check php.net for the header function (it has a few bits about authentification i believe).





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users