Advertisement
Guest User

Untitled

a guest
Oct 19th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1.  
  2. <HEAD>
  3. <link rel="stylesheet" type="text/css" href="css.css">
  4. <TITLE>
  5. Input Entry
  6. </TITLE>
  7. </HEAD>
  8. <BODY>
  9. <h1>Publish Chess Games</h1>
  10. <table>
  11. <form action='<?php echo $_SERVER["PHP_SELF"]; ?>' method="post" >
  12. <input name="GameID" type="number" id="GameID" placeholder="Enter an ID" required />
  13. <br>
  14. <input name="Date" type="date" id="Date" placeholder="Enter the Date" required />
  15. <br>
  16. <input name="Time" type="Time" id="Time" placeholder="Enter the time" required />
  17. <br>
  18. <input name="Location" type="text" id="Location" placeholder="Enter the location" required />
  19. <br>
  20. <input name="Player1" type="text" id="Player1" placeholder="Player (Black)" required />
  21. <br>
  22. <input name="Player2" type="text" id="Player2" placeholder="Player (White)" required />
  23. <br>
  24. <input name="Results" type="text" id="Results" placeholder="Enter the results" required />
  25. <br>
  26. <input name="AddInfo" type="text" id="AddInfo" placeholder="Additional information" required />
  27. <br>
  28.  
  29. <input type="submit">
  30. </form>
  31. </table>
  32. </BODY>
  33.  
  34. <?php
  35. if(isset($_POST['GameID'])) {
  36.  
  37. $mysql_host = "10.1.64.173";
  38. $mysql_username = "jake";
  39. $mysql_password = "abc123";
  40. $mysql_database = "chess club";
  41.  
  42. $conn = mysqli_connect($mysql_host, $mysql_username, $mysql_password, $mysql_database);
  43. if (mysqli_connect_error())
  44. {
  45. echo "Failed to connect to MySQL: " . mysqli_connect_error();
  46. }
  47. $GameID = $_POST['GameID'];
  48. $Date = $_POST['Date'];
  49. $Time = $_POST['Time'];
  50. $Location = $_POST['Location'];
  51. $Player1 = $_POST['Player1'];
  52. $Player2 = $_POST['Player2'];
  53. $Results = $_POST['Results'];
  54. $AddInfo = $_POST['AddInfo'];
  55.  
  56. $sql = "INSERT INTO `results` (`GameID`, `Date`, `Time`, `Location`, `Player (White)`, `Player (Black)`, `Results`, `Image`, `Additional Information`)
  57. VALUES ('$GameID', '$Date', '$Time', '$Location', '$Player1', '$Player2', '$Results', '', '$AddInfo')";
  58. $query = mysqli_query($conn, $sql);
  59. echo "Game ID " . $GameID . ", " . "Player (Black) " . $Player1 . ", " . "and Player (White) " . $Player2 . " have been inputted into the database";
  60.  
  61. ?>
  62. <?php } else { ?>
  63. <a>Uh oh!</a>
  64. <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement