<?php /* $host : your MySQL-host, usually 'localhost' */ /* $user : your MYSQL-username */ /* $password : your MySQL-password */ /* $database : your MySQL-database */ /* $table : your MySQL-table */ /* $page_title : the title of your guestbook-pages */ /* $admin_mail : email-address of the administrator to send the new entries to */ /* $admin_name : the name of the administrator */ /* $html_mail : say yes if your mail-agent can handle HTML-mail, else say no */
/* connect to the database */ mysql_pconnect("$host","$user","$password")ordie("Can't connect to the SQL-server"); mysql_select_db("$database");
/* action=view : retrieve data from the database and show it to the user */ if($action=="view"){
/* function for showing the data */ function search_it($name){
/* some vars */ global$offset,$total,$lpp,$dir; global$table,$html_mail,$admin_name,$admin_mail;
/* select the data to get out of the database */ $query="SELECT name, email, job, comments FROM $table"; $result=mysql_query($query); $total= mysql_numrows($result);
print"
" SIZE="
-2">.php3?action=add" onMouseOver="window.status='Add your name';returntrue" onMouseOut="window.status='';returntrue" TITLE="Add your name">加入留言
/* now really grab the data */ $i1=mysql_result($result,$counter,"name"); $i2=mysql_result($result,$counter,"email"); $i3=mysql_result($result,$counter,"job"); $i4=mysql_result($result,$counter,"comments");
/* MySQL really hates it when you try to put things with ' or " characters into a database, so strip these...*/ $comments=addslashes("$comments"); $query="INSERT INTO guestbook VALUES('','$name', '$email', '$job', '$comments')"; $result=MYSQL_QUERY($query);
?> <BR><PALIGN=CENTER>感谢,<?phpecho$name;?>, 您的留言. <BR><PALIGN=CENTER><AHREF="guestbook.php3?action=view"onMouseOver="window.status='View your comment now';return true"onMouseOut="window.status='';return true"TITLE="View your comment now">观看留言</A><BR><BR> <?
}
/* if there's no action given, then we must show the main page */ else{
/* get the number of entries written into the guestbook*/ $query="SELECT name from guestbook"; $result=MYSQL_QUERY($query); $number= MYSQL_NUMROWS($result);
if($number==""){ $entry="还没有人留过言";}
elseif($number=="1"){ $entry="目前留言人数1人";}
else{ $entry="目前留言人数 $number 人";}
echo"
"
; echo"
$entry "
; echo"
" SIZE="
3">.php3?action=add" onMouseOver="window.status='请您留言';returntrue" onMouseOut="window.status='';returntrue" TITLE="Add your name to our guestbook">请您留言";
if($number>""){ echo"
" SIZE="
3">.php3?action=view" onMouseOver="window.status='观看留言';returntrue" onMouseOut="window.status='';returntrue" TITLE="View the names in our guestbook">观看留言";} echo"