DimitriDV Posted November 25, 2008 Share Posted November 25, 2008 Hi there, I need to develop a webpage, only meant to be seen by one person. So, I'm planning to use a login BEFORE that webpage... Does anyone have a link how I do that? e.g. - http://www.mywebsite.be/hiddenpage - login & password - http://www.mywebsite.be/newpage (which cannot be seen via entering this direct link!) Frankly, I have no idea :-) *edit: there's a topic in here concerning php login: <?php /*Variables that are passed through the forum, assuming your forum has a password and username field.*/ $username = $_POST['username']; $password = md5($_POST['pass']); /*Everything related to database work.*/ mysql_connect ('localhost','username','password'); mysql_select_database ('database_name'); $query = "SELECT * FROM tablename WHERE username = '$username' AND password = '$password'"; //Assuming you have your 'tablename', and a 'username' and 'password' fields on your table. $result = mysql_query($query); //Throws the query and stores the value in the $result variable. $num = mysql_num_rows($result); //Now num has a value. If your site does NOT allow more than one unique username, the value on this variable will be either 1 or 0. /*Time to test.*/ if($num == 1){ //If there is a username with that password in the database: #Loggin successful! } else { //If there is not a username with that password: #Error loggin in! } ?> so actually, my question is: what do I write after if($num == 1){ //If there is a username with that password in the database: #Loggin successful! sorry if this is a dumb question but if I type someting like a redirect to a certain webpage, I'm still not convinced that people cannot access this webpage via a direct link! I need to have a mandatory login, even with a direct access... Link to comment https://forums.phpfreaks.com/topic/134182-secured-webpage/ Share on other sites More sharing options...
waynew Posted November 25, 2008 Share Posted November 25, 2008 You'll need to give them a session like so: if($num == 1){ $_SESSION['logged_in'] = true; //then redirect to secure page header('Location: securepage.php'); } Then on the secure page you must check to see if that user was given a session: if(!isset($_SESSION['logged_in'])){ //redirect to login form header('Location: login.php'); } //page contents Link to comment https://forums.phpfreaks.com/topic/134182-secured-webpage/#findComment-698485 Share on other sites More sharing options...
DimitriDV Posted November 25, 2008 Author Share Posted November 25, 2008 sorry guys, problem solved via some script I downloaded... http://www.globalissa.com/showcase.php?n=1&p=15 works fine! Link to comment https://forums.phpfreaks.com/topic/134182-secured-webpage/#findComment-698514 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.