Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("includes/dbconn.php");
- ?>
- <html>
- <head>
- </head>
- <?php
- function Login()
- {
- if(empty($_POST['Username']))
- {
- $this->HandleError("Username is empty!");
- return false;
- }
- if(empty($_POST['Password']))
- {
- $this->HandleError("Password is empty!");
- return false;
- }
- $username = trim($_POST['Username']);
- $password = trim($_POST['{Password']);
- if(!$this->CheckLoginInDB($Username,$Password))
- {
- return false;
- }
- session_start();
- $_SESSION[$this->GetLoginSessionVar()] = $Username;
- return true;
- }
- function CheckLoginInDB($username,$password)
- {
- if(!$this->DBLogin())
- {
- $this->HandleError("Database login failed!");
- return false;
- }
- $username = $this->SanitizeForSQL($username);
- $pwdmd5 = md5($password);
- $qry = "Select name, email from $this->tablename ".
- " where username='$username' and password='$pwdmd5' ".
- " and confirmcode='y'";
- $result = mysql_query($qry,$this->connection);
- if(!$result || mysql_num_rows($result) <= 0)
- {
- $this->HandleError("Error logging in. ".
- "The username or password does not match");
- return false;
- }
- return true;
- }
- ?>
- <footer>
- </footer>
- </html>
Add Comment
Please, Sign In to add comment