Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Comment</title>
- </head>
- <body>
- <?php
- $act = $_POST['act'];
- if($act == "post") {
- $name = $_POST['name'];
- $message = $_POST['message'];
- $code = $_POST['code'];
- @$fp = fopen("comments.php", 'a');
- if (strtolower($_POST['code']) != 'mycode') {
- //The file could not be opened
- echo "Password is wrong!";
- exit;
- } else {
- //The file was successfully opened, lets write the comment to it.
- $outputstring = "<br>Name: " .$name. "<br> Comment:<br>" .$message. "<br>";
- //Write to the file
- fwrite($fp, $outputstring, strlen($outputstring));
- //We are finished writing, close the file for security
- fclose($fp);
- //Post success
- echo "Your post was successfully entered. Click <a href='index.php'>here</a> to continue.";
- }
- } else {
- //show the form.
- ?>
- <h2>Previous comments:</h2>
- <?php include("comments.php"); ?>
- <br><br>
- <h2>Post a comment:</h2>
- <form action="index.php" method="post">
- <table>
- <tr>
- <td>Name:</td>
- <td><input type="text" name="name" value=""></input></td>
- </tr>
- <tr>
- <td>Comment:</td>
- <td><textarea name="message"></textarea></td>
- </tr>
- <tr>
- <td>Password:</td>
- <td><input type="text" name="code" value=""></input></td>
- </tr>
- </table>
- <input type="hidden" name="act" value="post"></input>
- <input type="submit" name="submit" value="Submit"></input>
- </form>
- <?php
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment