Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(-1);
- ini_set('display_errors', 'On');
- include("config.php");
- session_start();
- $link = mysqli_connect('mysql3.gear.host','baldwin','Baldwin1#','userinfo');
- if($_SERVER["REQUEST_METHOD"] == "POST") {
- // username and password sent from form
- $username = mysqli_real_escape_string($link, $_POST['username']);
- $password = mysqli_real_escape_string($link, $_POST['password']);
- $result = mysqli_query($link, "SELECT * FROM users WHERE username LIKE '$username' AND password LIKE '$password'");
- if($result === FALSE) {
- die(mysql_error()); // TODO: better error handling
- }
- while($row = mysqli_fetch_array($result))
- {
- echo $row['username'];
- }
- echo var_dump($result);
- $active = $row['active'];
- $count = mysqli_num_rows($result);
- // If result matched $username and $password, table row must be 1 row
- if($count == 1) {
- $_SESSION['login_user'] = $username;
- // check the user_type
- if($row["user_type"] == "teacher")
- {
- header("Location: teacher.php");
- }
- elseif($row["user_type"] == "parent")
- {
- header("Location: parent.php");
- }
- elseif($row ["user_type"] == "student")
- {
- header("Location: student.php");
- }
- elseif($row ["user_type" == "HOD")
- {
- header("Location: HOD.php");
- }
- else {
- echo "no account type!";
- }else {
- $error = "Your Login Name or Password is invalid";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement