WorldInChaos Posted January 10, 2007 Share Posted January 10, 2007 Hello everyone, I have a simple task, yet I believe I'm overthinking it, or missing the obvious.I am going to create user names and passes in a database table...and then I want a user to have to login to a certain area of our site using them.With this company, we will simply call them/email them their username and pass.I believe I have to use a basic Select user FROM table WHERE user=$userid AND pass=$passthen toss in a If statement for authentication...do I have an return statement - and how do I actually know then login?What prevents them from going straight to the page - do I have to define variables and send the url and POST user/pass?I'm more confused on how to/if create the admin page - if it's necessary. PHPMyAdmin does a fine job otherwise.If you have rather simple code for an administrative front end, that's great, but not necessary, although it would be helpful if I could 'login' to a page in order to add entries, or view/print the entire database from a page.This whole process doesn't have to be super-secure. It is only so everyone under the sun doesn't fill out a certain form on our site. Even if someone breaks in, the only thing they will see is a registration form for another part of a website. ::)This needs to be basic, I don't need any frills, and I know this has to have been done before. If you have any code or suggestions, please post them!Thanks!Steve Quote Link to comment Share on other sites More sharing options...
taith Posted January 10, 2007 Share Posted January 10, 2007 for example...login.php[code]<?if(!empty($_POST)){ $username=$_POST[username]; $password=md5($_POST[password]); $result=mysql_query("SELECT * FROM users WHERE `username`='$username' AND `password`='$password' LIMIT 1"); $row=mysql_fetch_array($result); if(!empty($row)) $_SESSION[user]=$row; else die("Invalid Username/Password");}?>[/code] Quote Link to comment Share on other sites More sharing options...
WorldInChaos Posted January 10, 2007 Author Share Posted January 10, 2007 Thanks much.I basically used that and some more input filtering.Like I said, it was rather easy - I just needed my memory jogged.Thanks for the help.Steven. 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.