Advertisement
Guest User

Untitled

a guest
Sep 17th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <?php
  2. session_start();
  3. if (!isset($_SESSION['username'])){
  4. header("location:../sdt/index.php");
  5.  
  6. }
  7. ?>
  8. <?php
  9. if (isset($_POST["username"]) && isset($_POST["password"])) {
  10.  
  11. $username = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["username"]);
  12. $password = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["password"]);
  13. include "connect_to_mysql.php";
  14. $sql = mysql_query("SELECT id FROM admin WHERE username='$username' AND password='$password' LIMIT 1");
  15. $existCount = mysql_num_rows($sql);
  16. if ($existCount == 1)
  17. while($row = mysql_fetch_array($sql)){
  18. $id = $row["id"];{
  19. }
  20. $_SESSION["id"] = $id;
  21. $_SESSION["username"] = $username;
  22. $_SESSION["password"] = $password;
  23. header("location:index.php");
  24. exit();
  25. } else {
  26. echo 'That information is incorrect, try again <a href="login.php">Click Here</a>';
  27. exit();
  28. }
  29. }
  30.  
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement