Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (isset($_POST['login']))
- { $username = mysqli_real_escape_string($con,$_POST['username']);
- $pwd = md5($_POST['password']);
- if (isset($username) == true && isset($pwd) == true){
- $login = login($username, $pwd);
- var_dump($login);
- if($login != null) {
- $_SESSION ['user_id'] = $login ['buss_id'];
- $_SESSION ['usernameholder'] = $login ['username'];
- ob_start();
- if ($login['level'] =='1')
- {?>
- <script>
- window.location.href = "sadmin/index.php";
- </script> <?php }
- else if($login['level'] =='2') { ?>
- <script>
- window.location.href = "user_admin/index.php";
- </script>
- <?php } else if($login['level'] =='3') { ?>
- <script>
- window.location.href = "reps/index.php";
- </script>
- <?php
- } /* end of login levels. */
- } /* /if $login !=null */
- } /* /if $login = login */
- } /* / if isset el $_POST */
- function login($username, $password)
- { $db_host="localhost";
- $db_username="root";
- $db_password="";
- $db_name="dbname";
- $con=mysqli_connect($db_host, $db_username,$db_password, $db_name);
- $qry = "SELECT * FROM `businesses` WHERE `username` = '$username' AND `password` = '$password' AND `active` = 1 LIMIT 1";
- $sql = mysqli_query($con,$qry);
- while($row = mysqli_fetch_array($sql))
- {
- return $row;
- } }
- $qry2 = "SELECT * FROM `employees` WHERE `username` = '$username2' AND `password` = '$password2' AND `active` = 1 LIMIT 1";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement