Login with different role : I am new to php. I could not log in either from the user or the admin. How do make it so the user could log in and will be redirected to index.php, and once the admin login will be redirected to admin.php. 

I did some research with youtube and could not find anything helpful on what I need.

---html

      <form action="login.php" method="post">

      <input class="space" name="username" type="text" 
      placeholder="Username/E- 
      mail" required="required"></input>

      <br />

      <input class="space" name="password" type="password" 
      placeholder="Password" required="required"></input>

      <br />

      <input type="submit" class="log-btn" value="Login" />

      <button type="button" class="log-btn" onclick="return 
      abc(1,'reg.html')">Register</button>

      </form>

[this is the database table][1]
I had also included the admin username and password in the database so admin does not have to register

---php

      <?php
      include ("conn.php");
      session_start();

      $sql="SELECT * FROM user WHERE email = '".$_REQUEST['username']."' and 
       password = '".$_REQUEST['password']."' or username = 
       '".$_REQUEST['username']."' and password = '".$_REQUEST['password']."' 
       LIMIT 1";
      $result=mysqli_query($con,$sql);

      if(mysqli_num_rows($result) <= 0)
      {
      $cred = mysqli_fetch_row($result);
      $_SESSION['user'] = $cred[1];
      echo "<script>window.location.href='index.php';</script>";
      }
      else
      echo "<script>window.location.href='index.php?msg=Invalid+Credential'; 
      </script>";
      if($row=mysqli_fetch_array($result))
      {
      $_SESSION['role']=$row['user_role'];
      }
      if($row['user_role']==="1"])
      {
      echo "<script>alert('Welcome back admin!');";
      echo "window.location.href='admin.html';</script>";
      }
      ?>

I expect that the user will be able to login and will be redirected to the index.php and the admin will be able to login as well as but will be redirected to the admin.pbp. But what I am seeing a white page and some error code on line 20. I know my if-else statement has some issue but not sure on how to fix it to be working 


  [1]: https://i.stack.imgur.com/owVvk.png