Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Part that sets up password in new.php
- $sql = "TRUNCATE TABLE tennisCoaches";
- $conn -> query($sql);
- if($password !== ""){
- $temp = md5($password);
- $sql = "INSERT INTO `tennisCoaches`(`password`) VALUES ( '$temp');";
- $conn -> query($sql);
- }
- $conn -> close();
- //coach.php stuff
- // And by that i mean everything up until i encapsulate the form/tables in an else{}...
- <!DOCTYPE html>
- <html lang="en">
- <?php
- session_start();
- $_SESSION["password"] = isset($_SESSION["password"]) ? $_SESSION["password"] : "";
- ?>
- <head>
- <meta charset="UTF-8">
- <title>Match Counter!</title>
- </head>
- <body>
- <div id="wins">
- <?php
- $servername = "devweb2017.cis.strath.ac.uk";
- $username = "ywb16155";
- $password = "xAtYbFaLTKjTGPtj";
- $database = "ywb16155";
- $conn = new mysqli($servername, $username, $password, $database);
- if (isset($_POST["password"])) {
- $_SESSION["password"] = $_POST["password"];
- }
- if ($conn -> connect_error){
- die ("connection failed ". mysqli_connect_error()); //remove once debugged
- }
- $sql = "SELECT * FROM `tennisCoaches`";
- $result = $conn->query($sql);
- $serverPass = $_POST["password"];
- if ($result->num_rows > 0) {
- while ($row = $result->fetch_assoc()) {
- $serverPass = $row["password"];
- }
- }
- if (md5($_SESSION["password"]) != $serverPass) {
- ?>
- <div>
- <h4>Please login if you are a coach.</h4>
- <form action="coach.php" method="POST">
- <p>
- Password: <input type="text" name="password" value=""/>
- </p>
- <p>
- <input type="submit" value="login"/>
- </p>
- </form>
- </div>
- <?php
- }else{
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement