Advertisement
Guest User

Untitled

a guest
Sep 18th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5. <title></title>
  6. </head>
  7. <body>
  8. <table border="1" align="center">
  9. <tr>
  10. <td>
  11. <form method="post" action="index.php">
  12. Your name :<br/>
  13. <input type="text" name="naam">
  14. <br/>
  15. Your message :<br/>
  16. <textarea name="bericht"></textarea>
  17. <br/>
  18. <input type="submit">
  19. <br/>
  20. </form>
  21. </td>
  22. </tr>
  23. <?php
  24. $mysql_user = "root";
  25. $mysql_pass = "";
  26. $mysql_database = "gastenboek";
  27. $mysql_server = "127.0.0.1";
  28.  
  29. $sql_connection = mysql_connect($mysql_server,$mysql_user,$mysql_pass);
  30. if (!$sql_connection)
  31. {
  32. die("Could not connect: " + mysql_error());
  33. }
  34. //echo "Connected<br>";
  35.  
  36. $sql_database = mysql_select_db($mysql_database,$sql_connection);
  37. if (!$sql_database)
  38. {
  39. die("Unable to select database: ".mysql_error());
  40. }
  41. //echo "Database selected.<br/><br/>";
  42.  
  43. if (isset($_POST["naam"]) && $_POST["naam"] != "" && isset($_POST["bericht"]) && $_POST["bericht"] != "")
  44. {
  45. mysql_query("INSERT INTO berichten (naam, bericht) VALUES('".$_POST["naam"]."', '".$_POST["bericht"]."')");
  46. }
  47.  
  48. $mysql_query = mysql_query("SELECT * FROM berichten");
  49. while ($row = mysql_fetch_array($mysql_query))
  50. {
  51. $date = $row[3];
  52. echo("<tr><td>".$row[1]." on ".$date." :<br/>");
  53. echo($row[2]."<br/><br/></tr></td>");
  54. }
  55. mysql_close();
  56. ?>
  57. </table>
  58. </body>
  59. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement