arifsor Posted February 16, 2007 Share Posted February 16, 2007 Hello i have a secure directory /cp/ with some password i want to create a page in php for checking password. any idea how? Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 16, 2007 Share Posted February 16, 2007 Do you have a username and password or just a password to access secure data? Quote Link to comment Share on other sites More sharing options...
arifsor Posted February 16, 2007 Author Share Posted February 16, 2007 basically i secure my online directory with user and password when i go to that page which is inside the directory, browser shows the promot for user name and password. i want to create a login page instead of it Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted February 16, 2007 Share Posted February 16, 2007 how is the username and password stored? have you secured the directory by using cPanel or is it done by php with the data being called from the MySQL database? Quote Link to comment Share on other sites More sharing options...
arifsor Posted February 16, 2007 Author Share Posted February 16, 2007 i secure the directory through cpanel Quote Link to comment Share on other sites More sharing options...
arifsor Posted February 16, 2007 Author Share Posted February 16, 2007 any idea??? Quote Link to comment Share on other sites More sharing options...
arifsor Posted February 16, 2007 Author Share Posted February 16, 2007 let me explain again. i am using a secure directory authantication for login on my site. ie. /cp/ is that possible to make a logout page for this kind of login. Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 16, 2007 Share Posted February 16, 2007 Would love to help, but I constructed mine with php and mysql. I have no idea what cPANEL is. Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 16, 2007 Share Posted February 16, 2007 cpannel is for hosting websites and within cpannel you add services for users have you got php and mysql within the cpannel app. Quote Link to comment Share on other sites More sharing options...
arifsor Posted February 16, 2007 Author Share Posted February 16, 2007 any one have any idea? Quote Link to comment Share on other sites More sharing options...
superuser2 Posted February 17, 2007 Share Posted February 17, 2007 Securing through cPanel secures it with .htaccess. I'm not sure if it's possible to use a php login form for .htaccess but know that might help someone else help you. Quote Link to comment Share on other sites More sharing options...
ataria Posted February 17, 2007 Share Posted February 17, 2007 Password Protect Directories ^ do that. Quote Link to comment Share on other sites More sharing options...
corbin Posted February 17, 2007 Share Posted February 17, 2007 You can recreate the effect of the .htaccess file with PHP using headers, but you would have to undo the .htaccess first. Quote Link to comment Share on other sites More sharing options...
marcus Posted February 17, 2007 Share Posted February 17, 2007 You can use PHP most definitely. Here's one I just made. I haven't tested it, but if any errors occur you could probably pick them out. On all pages add this: <?php if(!isset($_SESSION[logged])){ header("Location: login.php"); }else { //content } ?> //this will be login.php <?php session_start(); if(!isset($_SESSION[logged])){ if(!isset($_POST[action])){ echo "<table border=0 cellspacing=3 cellpadding=2>\n"; echo "<tr><td colspan=2 align=right><h3>Login</h3></td></tr>\n"; echo "<form name=login method=post action=login.php>\n"; echo "<tr><td>Username:</td><td><input type=text name=username value=''></td></tr>\n"; echo "<tr><td>Password:</td><td><input type=password name=password></td></tr>\n"; echo "<tr><td colspan=2 align=right><input type=hidden name=action value=login><input type=submit value='Login!'></td></tr>\n"; echo "</form></table>\n"; }else { if($_POST[action] == login){ $username = "setyourusernamehere"; $password = "setyourpasswordhere"; $un = $_POST[username]; $pw = $_POST[password]; if(isset($un) && isset($pw)){ if($un == $username && $pw == $password){ $_SESSION[logged] = "yes"; header("Location: index.php"); }else { echo "The username and password combination was incorrect!"; } }else { echo "You did not supply either a username or a password!"; } }else { echo "Error in the file!"; } } }else { header("Location: index.php"); } ?> Quote Link to comment Share on other sites More sharing options...
arifsor Posted February 17, 2007 Author Share Posted February 17, 2007 Thanks mgallforever, but i am not using form base login screen. i am using a password protected direcotry for login purpose. can we unset the server variables like $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted February 17, 2007 Share Posted February 17, 2007 i am not sure, never tried it, why dont you try it and see what happens. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.