Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- switch($_GET['s'])
- {
- case 'auth':
- auth();
- break;
- default:
- 'login';
- }
- function login()
- {
- global $c,$ir;
- if($_SESSION['loggedin'] == "1")
- {
- print"You are already logged in {$ir['username']}";
- exit;
- }
- else
- {
- print "<Form Action='index.php?p=login&s=auth' method='post'>
- Username: <input type='text' name='username'> <br />
- Password: <input type='password' name='password'> <br />
- <input type='submit' value='Login'></form>";
- }
- }
- function auth()
- {
- global $c,$ir;
- $pass=md5($_POST['password']);
- $q=mysql_query("SELECT * FROM users WHERE username='{$_POST['username']}' AND userpass='$pass'",$c);
- if(!$_POST['username'] || !$_POST['password'])
- {
- print "You must enter a username and password."
- exit;
- }
- if(!mysql_num_rows($q))
- {
- print "Invalid username/password";
- exit;
- }
- if($_SESSION['loggedin'] == "1")
- {
- print"You are already logged in {$ir['username']}";
- exit;
- }
- else
- {
- $r=mysql_fetch_array($q);
- $_SESSION['loggedin']=1;
- $_SESSION['user']=$r['userid'];
- print "You have successfully logged in {$r['username']}.";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement