Although the basic database guest book can be very beautiful and is better managed. However, for those friends who do not have a database space, text-based guestbooks can also be used for personal websites. And as long as we work hard to do it, we can do it well, and it can even be said that it is no worse than a database-based guestbook. Here I introduce a text-based guestbook. You can see its demonstration at the address below: /, it has the following two characteristics:
1. I use different faces to show the messages posted by different people;
2. Each commenter has the function of selecting small icons.
This guest book must consist of the following four files: a file that records the content of the message; a file that records the color of the message text; both files can be created with notepad. File that reflects the message form; file that finally processes the message information. Here are their source codes:
:
<html>
<head>
<title>===Message book===</title>
</head>
<body>
<form method="POST" action="">
Your name: <input type="text" name="name" size="44"><br>
Your email address: <input type="text" name="email" size="40"><br>
Your personal homepage: <input type="text" name="webname" size="40"><br>
Your personal homepage address: <input type="text" name="webadd" size="35"><br>
Your message: <br>
<textarea rows="2" name="note" cols="50"></textarea>
Please select the icon you like:
<input type="radio" value="1" checked name="icon"> <img border="0" src="" width="19" height="18">
<input type="radio" name="icon" value="2"> <img border="0" src="" width="16" height="16">
<input type="radio" name="icon" value="3"> <img border="0" src="" width="16" height="16">
<input type="radio" name="icon" value="4"> <img border="0" src="" width="19" height="18">
<input type="radio" name="icon" value="5"> <img border="0" src="" width="19" height="18">
<input type="radio" name="icon" value="6"> <img border="0" src="" width="19" height="18">
<input type="radio" name="icon" value="7"> <img border="0" src="" width="15" height="15">
<input type="radio" name="icon" value="8"> <img border="0" src="" width="19" height="18">
<input type="radio" name="icon" value="9"> <img border="0" src="" width="19" height="18">
<input type="radio" name="icon" value="10"> <img border="0" src="" width="18" height="18">
<input type="radio" name="icon" value="11"> <img border="0" src="" width="18" height="18">
<input type="radio" name="icon" value="12"> <img border="0" src="" width="18" height="18">
<input type="radio" name="icon" value="13"> <img border="0" src="" width="15" height="15">
<input type="radio" name="icon" value="14"> <img border="0" src="" width="18" height="18">
<input type="radio" name="icon" value="15"> <img border="0" src="" width="15" height="15">
</div>
<div align="left">
<input type="submit" value="send" name="B1"><input type="reset" value="rewrite" name="B2">
<a href="?primsg=1">View the message</a><br>
</div>
</form>
</body>
</html>
Among them: it is a small icon picture, you can change it yourself.
:
<?
if($primsg==1){
$f = fopen("","r");
$msg = fread($f,filesize(""));
fclose($f);
print "$msg"; }
else{
if ($name=="") {
print "You must leave me your name! Otherwise, how do I call you?<br>";}
else if ($note=="") {
print "You have to say something, right? Otherwise, what should I do if I click send? Could it be that I clicked wrong? Want to view the message??<br>";
}
else{
if ($email=="") {
print "I don't even leave my email address? How can I contact you? <br>";
}
else if ($webname==""||$webadd="") {
print "You don't have a personal homepage? If you still want you to leave me an address, it's okay to treat it as a promotion!"
}
$t = date(Y year m month d day);
$note = str_replace ( "<", "<", $note);
$note = str_replace ( ">", ">", $note);
$note = str_replace ( "\n", "<br>", $note);
$f = fopen("","r+");
$color1=fread($f,filesize(""));
if($color1==0){
$color=ff0000;}
else if($color1==1){
$color="0000ff";}
else if($color1==2){
$color="00ff00";
}
else if($color1==3){
$color="000000";
}
if($color1>=3){
$color1=0;}
else{
$color1+=1;
}
fseek($f,0);
fputs($f,$color1);
fclose($f);
for($I=1;$I<=15;$I++){
if($I==$icon){
$pic=$I;
}
}
$str=strval($pic);
$strhtml="<img src='n".$str.".gif'>";
$add="<a href=".$webadd."></a>";
$main = "$strhtml<br><font color=$color><a href=\"mailto:$email\">$name</a>             ($t)<br>
Say: $note <br>";
$f = fopen("","a");
fwrite($f,$main);
fclose($f);
$f = fopen("","r");
$msg = fread($f,filesize(""));
fclose($f);
echo"$msg";
}
}
?>
1. I use different faces to show the messages posted by different people;
2. Each commenter has the function of selecting small icons.
This guest book must consist of the following four files: a file that records the content of the message; a file that records the color of the message text; both files can be created with notepad. File that reflects the message form; file that finally processes the message information. Here are their source codes:
:
<html>
<head>
<title>===Message book===</title>
</head>
<body>
<form method="POST" action="">
Your name: <input type="text" name="name" size="44"><br>
Your email address: <input type="text" name="email" size="40"><br>
Your personal homepage: <input type="text" name="webname" size="40"><br>
Your personal homepage address: <input type="text" name="webadd" size="35"><br>
Your message: <br>
<textarea rows="2" name="note" cols="50"></textarea>
Please select the icon you like:
<input type="radio" value="1" checked name="icon"> <img border="0" src="" width="19" height="18">
<input type="radio" name="icon" value="2"> <img border="0" src="" width="16" height="16">
<input type="radio" name="icon" value="3"> <img border="0" src="" width="16" height="16">
<input type="radio" name="icon" value="4"> <img border="0" src="" width="19" height="18">
<input type="radio" name="icon" value="5"> <img border="0" src="" width="19" height="18">
<input type="radio" name="icon" value="6"> <img border="0" src="" width="19" height="18">
<input type="radio" name="icon" value="7"> <img border="0" src="" width="15" height="15">
<input type="radio" name="icon" value="8"> <img border="0" src="" width="19" height="18">
<input type="radio" name="icon" value="9"> <img border="0" src="" width="19" height="18">
<input type="radio" name="icon" value="10"> <img border="0" src="" width="18" height="18">
<input type="radio" name="icon" value="11"> <img border="0" src="" width="18" height="18">
<input type="radio" name="icon" value="12"> <img border="0" src="" width="18" height="18">
<input type="radio" name="icon" value="13"> <img border="0" src="" width="15" height="15">
<input type="radio" name="icon" value="14"> <img border="0" src="" width="18" height="18">
<input type="radio" name="icon" value="15"> <img border="0" src="" width="15" height="15">
</div>
<div align="left">
<input type="submit" value="send" name="B1"><input type="reset" value="rewrite" name="B2">
<a href="?primsg=1">View the message</a><br>
</div>
</form>
</body>
</html>
Among them: it is a small icon picture, you can change it yourself.
:
<?
if($primsg==1){
$f = fopen("","r");
$msg = fread($f,filesize(""));
fclose($f);
print "$msg"; }
else{
if ($name=="") {
print "You must leave me your name! Otherwise, how do I call you?<br>";}
else if ($note=="") {
print "You have to say something, right? Otherwise, what should I do if I click send? Could it be that I clicked wrong? Want to view the message??<br>";
}
else{
if ($email=="") {
print "I don't even leave my email address? How can I contact you? <br>";
}
else if ($webname==""||$webadd="") {
print "You don't have a personal homepage? If you still want you to leave me an address, it's okay to treat it as a promotion!"
}
$t = date(Y year m month d day);
$note = str_replace ( "<", "<", $note);
$note = str_replace ( ">", ">", $note);
$note = str_replace ( "\n", "<br>", $note);
$f = fopen("","r+");
$color1=fread($f,filesize(""));
if($color1==0){
$color=ff0000;}
else if($color1==1){
$color="0000ff";}
else if($color1==2){
$color="00ff00";
}
else if($color1==3){
$color="000000";
}
if($color1>=3){
$color1=0;}
else{
$color1+=1;
}
fseek($f,0);
fputs($f,$color1);
fclose($f);
for($I=1;$I<=15;$I++){
if($I==$icon){
$pic=$I;
}
}
$str=strval($pic);
$strhtml="<img src='n".$str.".gif'>";
$add="<a href=".$webadd."></a>";
$main = "$strhtml<br><font color=$color><a href=\"mailto:$email\">$name</a>             ($t)<br>
Say: $note <br>";
$f = fopen("","a");
fwrite($f,$main);
fclose($f);
$f = fopen("","r");
$msg = fread($f,filesize(""));
fclose($f);
echo"$msg";
}
}
?>