Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. <?php
  2.  
  3. if($_SERVER["REQUEST_METHOD"] == "POST") {
  4.  
  5. // Connect to server and select databse.
  6. mysql_connect("$host", "$username", "$password")or die("cannot connect");
  7. mysql_select_db("$db_name")or die("cannot select DB");
  8.  
  9. // username and password sent from form
  10. $username=$_POST['username'];
  11. $password=$_POST['password'];
  12.  
  13. // To protect MySQL injection (more detail about MySQL injection)
  14. $username = stripslashes($username);
  15. $password = stripslashes($password);
  16. $username = mysql_real_escape_string($username);
  17. $password = mysql_real_escape_string($password);
  18. $sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password'";
  19. $result=mysql_query($sql);
  20.  
  21. // Mysql_num_row is counting table row
  22. $count=mysql_num_rows($result);
  23.  
  24. // If result matched $myusername and $mypassword, table row must be 1 row
  25. if($count==1){
  26. // Register $username, $password and redirect to file "index.php"
  27. session_register("username");
  28. session_register("password");
  29. if($username == "vuk" || $username == "petar" || $username == "jelena" || $username == "irena" || $username == "test") {
  30. $_SESSION['loggedin'] = true;
  31. $_SESSION['username'] = $username;
  32. echo '
  33. <script type="text/javascript">
  34.  
  35. window.location = "http://heroindetoxeurope.com/crm/vorobjev/index.php"
  36.  
  37. </script>';
  38. }
  39. else if ($username == "admin" || $username == "dusan"){
  40. $_SESSION['loggedin'] = true;
  41. $_SESSION['username'] = $username;
  42. echo '
  43. <script type="text/javascript">
  44.  
  45. window.location = "http://heroindetoxeurope.com/crm/vorobjev/index1.php"
  46.  
  47. </script>';
  48. }
  49. }
  50. else {
  51. $error = "Pogresna kombinacija korisnickog imena i lozinke!";
  52. }
  53. }
  54. ?>
  55. <html>
  56. <head>
  57. <title>User Login - Management system</title>
  58. <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
  59. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
  60. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  61. <link rel="stylesheet" type="text/css" href="css/login.css"/>
  62. <link rel="shortcut icon" type="image/ico" href="images/fav.ico"/>
  63. </head>
  64.  
  65. <body>
  66. <div class="container" style="margin-top: 200px;">
  67. <?php if(isset($smsg)){ ?>
  68. <div class="alert alert-success" role="alert">
  69. <?php echo $smsg; ?>
  70. </div>
  71. <?php } ?>
  72. <?php if(isset($fmsg)){ ?>
  73. <div class="alert alert-danger" role="alert">
  74. <?php echo $fmsg; ?>
  75. </div>
  76. <?php } ?>
  77. <form name="login-form" class="login-form" method="post">
  78. <div class="header">
  79. <h1 style="text-align: center;">Dr Vorobjev Management System</h1>
  80. </div>
  81. <div class="content">
  82. <input name="username" type="text" class="input username" placeholder="Username" name="username" required="" />
  83. <div class="user-icon"></div>
  84. <input name="password" type="password" class="input password" placeholder="Password" name="password" required="" />
  85. <div class="pass-icon"></div>
  86. </div>
  87. <div class="footer">
  88. <button class="button" type="submit">Login</button>
  89. </div>
  90. </form>
  91. <div style = "font-size:11px; color:#cc0000; margin-top:10px; text-align: center;"><?php echo $error; ?></div>
  92. </div>
  93. </body>
  94. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement