hi all i am a complete newbie to this php so bear with me have done searches for login and they all seem very complicated to work out all i want is a simple login php that just checks username and pass word from my database not to worried at the moment about encryption and that till i learn more i have database set up and registration set up just need login check many thanks Doug
thanks for the reply but havnt got a clue about what you suggest like i said total newbie cheers Doug
OK sorry. http://www.javascriptkit.com/howto/htaccess3.shtml And http://www.google.co.uk/search?hl=e...&q=htaccess+tutorial+password+protect&spell=1 If you don't need to display the log in person's name, or access their data or anything, this is the easiest and possibly the most secure way to protect certain files. You place the htaccess file in the root and the password file somewhere outside the public tree, that's it. No database needed.
thanks again for that what it is for is on my web site i have 2 choices free view page and a member page and reg page so that peeps can reg them selves then view members page with out me having to do any thing if you understand what i mean if you want to have a look addy is www.caravan-holiday-exchange.com you can see members page at moment thats why i need the login cheers Doug
Here is the login check script that I use. You will have to edit it, but it shouldn't be that hard. You might have to change the config.php file to your database connection file. <?php include("config.php"); $username = $_SESSION['username']; if (!isset($_SESSION['logged_in'])) { if (!isset($_POST['check_login'])) { echo" <table width='300' border='0' align='center' cellpadding='0' cellspacing='1' bgcolor='#CCCCCC'> <tr> <form name='form' action='login.php' method='POST'> <td> <table width='100%' border='0' cellpadding='3' cellspacing='1' bgcolor='#FFFFFF'> <tr> <td colspan='3'><strong>Member Login </strong></td> </tr> <tr> <td width='78'>Username</td> <td width='6'>:</td> <td width='294'><input name='username' type='text' /></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name='password' type='password' /></td> </tr> <tr> <td><a href='register.php?action=new'>New User</a></td> <td> </td> <td><input type='submit' name='check_login' value='Log In' /></td> </tr> </table> </td> </form> </tr> </table>"; } elseif (isset($_POST['check_login'])) { $username = $_POST['username']); $password = md5($_POST['password']); if (empty($password) || empty($username)) { echo"You left a field blank!"; } else { $check_login_query = "SELECT `username`, `password`, `id` FROM `members` WHERE `username` = '$username' AND password = '$password' LIMIT 1"; $check_login = mysql_query($check_login_query); if (mysql_num_rows($check_login) > 0) { $_SESSION['logged_in'] = 1; $_SESSION['username'] = $username; echo"You have successfully logged in! You will be redirected in three seconds!><br /><br /> <div class='info'>If you don't wish to wait, <a href='index.php'>click here</a>"; echo'<meta http-equiv="REFRESH" content="3;url=index.php">'; } else { echo"You have supplied an invalid username and/or password!"; } } } } ?> Code (markup):
thanks to all for the help but it is to hard for understand at my age so have given up for now thanks Doug
you can make simple login system using Cookie.it is not that secure,but you can use it.just post the username and password in a page,check if it and if it ok then set the cookie with any value. example setcookie('logged','yes',time()+14*60*60); now in the pages where u want check if the user is logged in or not then you can just check if the 'logged' Cookie's value is 'yes'.if it is 'yes' then ok otherwise you can redirect them to login page. i hope it will help you coderbari's homepage
check http://www.legend.ws/blog/tips-tricks/php-authentication-login-script/ upload a file and add 1 line.