Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static function login()
- {
- if(isset($_POST['username']))
- {
- if(empty($_POST['username']))
- {
- print 'Username field was empty, please try again.';
- return;
- }
- if(empty($_POST['password']))
- {
- print 'Password field was empty, please try again.';
- return;
- }
- $encrypt = sha1(strtoupper($_POST['username'].':'.$_POST['password']));
- $q = mysql_query("SELECT * FROM users WHERE user = '$_POST[username]' AND password = '$encrypt' LIMIT 1") or die(mysql_error());
- if(!mysql_num_rows($q) == 0)
- {
- $row = mysql_fetch_assoc($q); //We only need one result, so ditch the while
- $row['admin'] = $row['user']
- //Transfer row data to the session
- foreach($row as $k => $v)
- {
- $_SESSION[$k] = $v;
- }
- $_SESSION['user'] = $_POST['username'];
- print '<center><img src="images/loader.gif" /> submitting information..</center>';
- header("Location: ./");
- }
- else
- {
- print 'Couldn\'t log you in, please try again.';
- return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement