Skip to content

Instantly share code, notes, and snippets.

@lornajane
Created August 16, 2011 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lornajane/1149035 to your computer and use it in GitHub Desktop.
Save lornajane/1149035 to your computer and use it in GitHub Desktop.
comments
<h1>Submit A Comment</h1>
<form method="post">
<p>Name: <input name="name" /></p>
<p>Comment: <textarea name="comment"></textarea></p>
<input type="submit" />
</form>
<?php
if($_POST) {
$comment['name'] = $_POST['name'];
$comment['comment'] = $_POST['comment'];
$_SESSION['comments'][] = $comment;
}
if(isset($_SESSION['comments'])) {
foreach($_SESSION['comments'] as $comment) {
echo "Comment from <b>" . $comment['name'] . "</b>: <br />\n";
echo nl2br($comment['comment']);
echo "<hr />\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment