Advertisement
Guest User

Untitled

a guest
Mar 14th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. <?php
  2. session_start();
  3. if(isset($_POST['submit'])){
  4. $con = mysqli_connect("localhost","root","","imetrics");
  5.  
  6. $username = $_POST['username'];
  7. $password = $_POST['password'];
  8.  
  9.  
  10. $user = mysqli_query($con, "SELECT * FROM user WHERE password='$password' AND username='$username'")or die("Cannot connect");
  11. $count = mysqli_num_rows($user);
  12.  
  13. if($count > 0) {
  14. $row = mysqli_fetch_assoc($user);
  15.  
  16. if($row['usertype'] == 'Client'){
  17. $_SESSION['username'] = $_POST['username'];
  18. header("location:a.php");
  19. }
  20. else{
  21. $_SESSION['username'] = $_POST['username'];
  22. header("location:takesurvey.php");
  23.  
  24. }
  25. }
  26. else{
  27. echo '<script language="javascript">';
  28. echo 'alert("Wrong username/password")';
  29. echo '</script>';
  30. }
  31. }
  32.  
  33. ?>
  34. <html>
  35.  
  36. <head></head>
  37. <body>
  38.  
  39. <form method="POST" >
  40.  
  41. <div class="row form-group">
  42. <div class="col-sm-12">
  43. <input type="text" name="username" id="username" class="form-control" placeholder="Username">
  44. </div>
  45. </div>
  46.  
  47. <div class="row form-group">
  48. <div class="col-sm-12">
  49. <input type="password" name="password" id="password" class="form-control" placeholder="Password">
  50. </div>
  51. </div>
  52.  
  53. <div class="row form-group">
  54. <div class="col-sm-12">
  55. <input type="submit" name="submit" class="form-control btn btn-primary" value="Login">
  56. </div>
  57. </div>
  58.  
  59. </form>
  60.  
  61. </body>
  62.  
  63. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement