Advertisement
Guest User

EDIN

a guest
Jan 22nd, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. VERSTUREN.PHP
  2.  
  3. <?php
  4. $servername = "localhost";
  5. $username = "mt13-c-groep2";
  6. $password = "evwqfT";
  7. $dbname = "dbmt13-c-groep2";
  8.  
  9. // Create connection
  10. $conn = new mysqli($servername, $username, $password, $dbname);
  11. // Check connection
  12. if ($conn->connect_error) {
  13. die("Connection failed: " . $conn->connect_error);
  14. }
  15.  
  16. $score = $_POST['score'];
  17. $naam = $_POST['naam'];
  18.  
  19. $sql = "INSERT INTO score (ID, naam, score)
  20. VALUES ('NULL', '$naam', '$score')";
  21.  
  22. if ($conn->query($sql) === TRUE) {
  23. echo "New record created successfully";
  24. } else {
  25. echo "Error: " . $sql . "<br>" . $conn->error;
  26. }
  27.  
  28. $conn->close();
  29. ?>
  30.  
  31.  
  32.  
  33. <form action="versturen.php" method="post">
  34. <p>Score:<input type="text" name="score" required><br />
  35. Naam:<input type="text" name="naam" required><br /></p>
  36. <input type="submit" value="submit">
  37. </form><br>
  38. <div id="scoreboard">
  39.  
  40. SCOREBOARD.HTML
  41.  
  42. <?php
  43. $servername = "localhost";
  44. $username = "mt13-c-groep2";
  45. $password = "evwqfT";
  46. $dbname = "dbmt13-c-groep2";
  47.  
  48. // Create connection
  49. $conn = new mysqli($servername, $username, $password, $dbname);
  50. // Check connection
  51. if ($conn->connect_error) {
  52. die("Connection failed: " . $conn->connect_error);
  53. }
  54.  
  55. $result = mysqli_query($conn,"SELECT * FROM score");
  56.  
  57. echo "<table border='1'>
  58. <tr>
  59. <th>score</th>
  60. <th>naam</th>
  61. </tr>";
  62.  
  63. while($row = mysqli_fetch_array($result))
  64. {
  65. echo "<tr>";
  66. echo "<td>" . $row['score'] . "</td>";
  67. echo "<td>" . $row['naam'] . "</td>";
  68. echo "</tr>";
  69. }
  70. echo "</table>";
  71.  
  72. mysqli_close($conn);
  73.  
  74.  
  75. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement