Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <HEAD>
- <link rel="stylesheet" type="text/css" href="css.css">
- <TITLE>
- Input Entry
- </TITLE>
- </HEAD>
- <BODY>
- <h1>Publish Chess Games</h1>
- <table>
- <form action='<?php echo $_SERVER["PHP_SELF"]; ?>' method="post" >
- <input name="GameID" type="number" id="GameID" placeholder="Enter an ID" required />
- <br>
- <input name="Date" type="date" id="Date" placeholder="Enter the Date" required />
- <br>
- <input name="Time" type="Time" id="Time" placeholder="Enter the time" required />
- <br>
- <input name="Location" type="text" id="Location" placeholder="Enter the location" required />
- <br>
- <input name="Player1" type="text" id="Player1" placeholder="Player (Black)" required />
- <br>
- <input name="Player2" type="text" id="Player2" placeholder="Player (White)" required />
- <br>
- <input name="Results" type="text" id="Results" placeholder="Enter the results" required />
- <br>
- <input name="AddInfo" type="text" id="AddInfo" placeholder="Additional information" required />
- <br>
- <input type="submit">
- </form>
- </table>
- </BODY>
- <?php
- if(isset($_POST['GameID'])) {
- $mysql_host = "10.1.64.173";
- $mysql_username = "jake";
- $mysql_password = "abc123";
- $mysql_database = "chess club";
- $conn = mysqli_connect($mysql_host, $mysql_username, $mysql_password, $mysql_database);
- if (mysqli_connect_error())
- {
- echo "Failed to connect to MySQL: " . mysqli_connect_error();
- }
- $GameID = $_POST['GameID'];
- $Date = $_POST['Date'];
- $Time = $_POST['Time'];
- $Location = $_POST['Location'];
- $Player1 = $_POST['Player1'];
- $Player2 = $_POST['Player2'];
- $Results = $_POST['Results'];
- $AddInfo = $_POST['AddInfo'];
- $sql = "INSERT INTO `results` (`GameID`, `Date`, `Time`, `Location`, `Player (White)`, `Player (Black)`, `Results`, `Image`, `Additional Information`)
- VALUES ('$GameID', '$Date', '$Time', '$Location', '$Player1', '$Player2', '$Results', '', '$AddInfo')";
- $query = mysqli_query($conn, $sql);
- echo "Game ID " . $GameID . ", " . "Player (Black) " . $Player1 . ", " . "and Player (White) " . $Player2 . " have been inputted into the database";
- ?>
- <?php } else { ?>
- <a>Uh oh!</a>
- <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement