Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class user {
- oublic $usrname; // Username
- public $usrpassword; // Password
- public function login($usrname, $usrpassword) {
- // check DB
- if (mysqli_connect_errno()) { // if mysql connection fails
- echo "<p>Fejl i tilslutning til database</p> ";
- exit;
- }
- $this->usrname = $usrname;
- $this->usrpassword= md5($usrpassword);
- $result=$mysqli->query("SELECT * FROM sl_users WHERE username='$this->usrname' and password='$this->usrpasswor' "); // Query user/pass in db
- $count=mysql_num_rows($result);
- if($count==1){ // If username and password matches 1 line in the database
- session_register("usrname");
- session_register("online");
- $_SESSION['online'] = 1;
- }
- else {
- echo '<p>Forkert brugernavn eller adgangskode!</p>'; // Incorrect username/password // mismatch in database
- }
- $mysqli->close();
- }
- public function logout() {
- session_destroy(usrname);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement