Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title></title>
- </head>
- <body>
- <table border="1" align="center">
- <tr>
- <td>
- <form method="post" action="index.php">
- Your name :<br/>
- <input type="text" name="naam">
- <br/>
- Your message :<br/>
- <textarea name="bericht"></textarea>
- <br/>
- <input type="submit">
- <br/>
- </form>
- </td>
- </tr>
- <?php
- $mysql_user = "root";
- $mysql_pass = "";
- $mysql_database = "gastenboek";
- $mysql_server = "127.0.0.1";
- $sql_connection = mysql_connect($mysql_server,$mysql_user,$mysql_pass);
- if (!$sql_connection)
- {
- die("Could not connect: " + mysql_error());
- }
- //echo "Connected<br>";
- $sql_database = mysql_select_db($mysql_database,$sql_connection);
- if (!$sql_database)
- {
- die("Unable to select database: ".mysql_error());
- }
- //echo "Database selected.<br/><br/>";
- if (isset($_POST["naam"]) && $_POST["naam"] != "" && isset($_POST["bericht"]) && $_POST["bericht"] != "")
- {
- mysql_query("INSERT INTO berichten (naam, bericht) VALUES('".$_POST["naam"]."', '".$_POST["bericht"]."')");
- }
- $mysql_query = mysql_query("SELECT * FROM berichten");
- while ($row = mysql_fetch_array($mysql_query))
- {
- $date = $row[3];
- echo("<tr><td>".$row[1]." on ".$date." :<br/>");
- echo($row[2]."<br/><br/></tr></td>");
- }
- mysql_close();
- ?>
- </table>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement