<?php

session_start();
require_once "functions.php";
$user = new loginRegistration();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $user_name = $_POST['user_name'];
    $password = $_POST['password'];
    if (empty($user_name) or empty($password)) {
        echo "<h4>Every field should be filup </h4>";
    } else {
        $password = md5($password);
        $login = $user->userLogin($user_name, $password);
        if ($login) {
            $cech = $user->checkscope();
            if ($cech == true) {
                $wait = $user->userwait($user_name);
                header('Location:wait.php ');
            } else {
                header('Location:chat.php');
            }
        } else {
            echo "Invalid username or password";
        }
    }
}
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
<?php

session_start();
require_once "functions.php";
header('Refresh: 10; url=finalwait.php');
$user = new loginRegistration();
$hh = $user->checkscope();
if ($hh == false) {
    $deletefr = $user->deletefromfinalwait();
    header('Location:chat.php');
}
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Waiting Room</title>
    <!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<link href="css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
    body{ background:url(images/b1.jpg) no-repeat center top scroll;