Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require 'connect.php';
  4. echo "Test";
  5.  
  6. //Hash passwords using MD5 hash (32bit string).
  7. $username=($_POST['username']);
  8. $password=MD5($_POST['password']);
  9.  
  10. //Get required information from admin_logins table
  11. $sql=mysql_query("SELECT * FROM admin_logins WHERE Username='$username' ");
  12. $row=mysql_fetch_array($sql);
  13.  
  14. //Check that entered username is valid by checking returned UserID
  15. if($row['UserID'] === NULL){
  16. header("Location: ../adminlogin.php?errCode=UserFail");
  17. }
  18. //Where username is correct, check corresponding password
  19. else if ($row['UserID'] != NULL && $row['Password'] != $password){
  20. header("Location: ../adminlogin.php?errCode=PassFail");
  21. }
  22. else{
  23. $_SESSION['isAdmin'] = true;
  24. header("Location: ../admincontrols.php");
  25. }
  26.  
  27. mysql_close($con);
  28.  
  29. ?>
  30.  
  31. <?php
  32. $con = mysql_connect("localhost","username","password");
  33. if(!$con) {
  34. die('Could not connect: ' . mysql_error());
  35. }
  36. mysql_select_db("dbname", $con);
  37. ?>
  38.  
  39. SELECT *
  40. FROM admin_logins
  41. WHERE `Username` = '$username'
  42.  
  43. <?php
  44. $stmt = $dbh->prepare("SELECT * FROM admin_logins WHERE `Username` = ?");
  45. $stmt->bindParam(1, $username);
  46. if ($stmt->execute(array($_GET['name']))) {
  47. while ($row = $stmt->fetch()) {
  48. print_r($row);
  49. }
  50. }
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement