Advertisement
Guest User

Untitled

a guest
Oct 27th, 2017
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. //Part that sets up password in new.php
  2. $sql = "TRUNCATE TABLE tennisCoaches";
  3. $conn -> query($sql);
  4.  
  5. if($password !== ""){
  6. $temp = md5($password);
  7. $sql = "INSERT INTO `tennisCoaches`(`password`) VALUES ( '$temp');";
  8. $conn -> query($sql);
  9. }
  10.  
  11. $conn -> close();
  12.  
  13.  
  14. //coach.php stuff
  15. // And by that i mean everything up until i encapsulate the form/tables in an else{}...
  16.  
  17. <!DOCTYPE html>
  18. <html lang="en">
  19.  
  20. <?php
  21. session_start();
  22. $_SESSION["password"] = isset($_SESSION["password"]) ? $_SESSION["password"] : "";
  23. ?>
  24.  
  25. <head>
  26. <meta charset="UTF-8">
  27. <title>Match Counter!</title>
  28.  
  29. </head>
  30. <body>
  31. <div id="wins">
  32. <?php
  33. $servername = "devweb2017.cis.strath.ac.uk";
  34. $username = "ywb16155";
  35. $password = "xAtYbFaLTKjTGPtj";
  36. $database = "ywb16155";
  37. $conn = new mysqli($servername, $username, $password, $database);
  38.  
  39. if (isset($_POST["password"])) {
  40. $_SESSION["password"] = $_POST["password"];
  41. }
  42.  
  43. if ($conn -> connect_error){
  44. die ("connection failed ". mysqli_connect_error()); //remove once debugged
  45. }
  46.  
  47.  
  48. $sql = "SELECT * FROM `tennisCoaches`";
  49. $result = $conn->query($sql);
  50.  
  51. $serverPass = $_POST["password"];
  52. if ($result->num_rows > 0) {
  53. while ($row = $result->fetch_assoc()) {
  54. $serverPass = $row["password"];
  55. }
  56. }
  57.  
  58. if (md5($_SESSION["password"]) != $serverPass) {
  59. ?>
  60. <div>
  61. <h4>Please login if you are a coach.</h4>
  62. <form action="coach.php" method="POST">
  63. <p>
  64. Password: <input type="text" name="password" value=""/>
  65. </p>
  66. <p>
  67. <input type="submit" value="login"/>
  68. </p>
  69. </form>
  70. </div>
  71. <?php
  72. }else{
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement