
9:43:55 pm, Friday, November 21, 2008
Anita Scripter © 2007 - All Rights Reserved
<?php
//include header
include ("header.inc");
// include Content
include ("content.inc");
include ("functions.inc");
$len_name = 25;
$file_name = "guest.txt";
$replace_data =" ";
$string_data1 = "$name";
$string_data2 = "$email";
$string_data3 = "$country";
$string_data4 = "$website";
$string_data5 = "$comment";
if (!empty($name)) {
//check the length of name & phone
if ((strlen($string_data1)) > $len_name) {
// if input > size limit
echo "<p>Your name is way too durn long!</p>";
$name = "";
include ("form.inc");
die();
}
if (validate_email($string_data2)) {
echo $valid;
} else {
echo "<p>E-mail is invalid! ";
echo "Please enter a valid e-mail address.</p>";
include ("form.inc");
exit;
}
//combine data
$string_data6 = str_replace( "\n", " ", $string_data5 );
$new_entry = $string_data1."|".$string_data2."|".$string_data3."|".$string_data4."|".$string_data5."\n";
$file_handle = fopen("$file_name","ab+");
fwrite($file_handle, $new_entry);
fclose($file_handle);
$file_handle = fopen("$file_name","rb");
$fsize = filesize ($file_name);
$data = fread($file_handle, filesize ($file_name));
$num_lines = count(file($file_name));
$lines = split("\n",$data);
//list it nicely
print "<h3>Thank you for signing my guestbook!</h3>";
for ($i = 1; $i <= $num_lines -1; $i++) {
list($name,$email,$country,$website,$comment) = split('\|',$lines[$i],5);
print "<p class='gb'>";
print "Entry # $i <br />";
print "Name: $name<br />\n";
print "E-mail: $email<br />\n";
print "Country: $country<br />\n";
print "Web Site: $website<br />\n";
print "Comment: $comment<br />\n";
print "</p>";
}
fclose($file_handle);
} else {
include ("form.inc");
include ("vgb.inc");
}
//include footer
include ('footer.inc');
?>