Llamasery.com Home  
 
Server-side Tutorial/Article: Visitor Comments - Part 2 of 6
Alfie the alpha_geek: Llamasery guru-in-waiting Tutorials Purpose

Tutorials/Articles

Rate This
Visitor Comments
Feeling Secure
News & Events

Starter Tutorials

Starter Tutorials

Second: Collecting the visitor comments/information

This is a simple form, basically the same type of form as we discussed elsewhere (in the starter tutorials). Our form needs to collect the visitor's information and comments, and we'll also generate the visitor IP address and server GMT time/date automatically (as we did in the Contact Form in starter tutorials). These may be useful later if there are troubles with unacceptable comments or someone spamming the comments system.

<form action="comments2.php" method="post">

// get the page id to which these comments apply
<?
echo "<input type='hidden' name='page_id' value='" .$page_id. "' />";

// get the IP address and time sent
$ip = getenv("REMOTE_ADDR");
echo "<input type='hidden' name='ip' value='" .$ip. "' />";
$dated = gmdate("h:i a"). " [GMT] on ". gmdate("F d Y");
echo "<input type='hidden' name='dated' value='" .$dated. "' />";
?>
Your name:<br />
<input type="text" name="name" /><br />
Your location:<br />
<input type="text" name="locn" /><br />
Your comments:<br />
<textarea cols="30" rows="5" name="comments"></textarea>
<input type="text" name="submit" value="Add Comments" />
</form>

A complete script download is available later, so there's no need to save the code above (unless you really want to). Now we'll move on to scripting how to handle that form and add the inputs to our database.

«  previous  |  next  »