Can anyone add a script to this guestbook script.a script that adds 1 point every post they made. I have a column in named 'postcount' and the properties are int(10) unsigned defualt 0..and the table i'm using is users NOT guest.
<?
session_start();
$link = mysql_connect('localhost','cha', '')
or die("Could not connect");
mysql_select_db('c')
or die("Could not select database");
$query = "SELECT * from users WHERE username='$user_name'";
$show = mysql_query($query);
while ($row=mysql_fetch_array($show))
{
echo $row[ghtml];
}
////////////////////////////////
// This checks to see if we need to add another guestbook entry.
////////////////////////////////
if (($REQUEST_METHOD=='POST')) {
////////////////////////////////
// This loop removed "dangerous" characters from the posted data
// and puts backslashes in front of characters that might cause
// problems in the database.
////////////////////////////////
for(reset($HTTP_POST_VARS);
$key=key($HTTP_POST_VARS);
next($HTTP_POST_VARS)) {
$this = addslashes($HTTP_POST_VARS[$key]);
$this = strtr($this, ">", " ");
$this = strtr($this, "<", " ");
$this = strtr($this, "|", " ");
$$key = $this;
}
////////////////////////////////
// This will catch if someone is trying to submit a blank
// or incomplete form.
////////////////////////////////
if ( $message ) {
////////////////////////////////
// This is the meat of the query that updates the guests table
////////////////////////////////
$userses = $_SESSION['edithtml'];
$query = "SELECT * from image WHERE userf='$userses'";
$show = mysql_query($query);
while ($row=mysql_fetch_array($show))
{
$image = $row[urler];
}
$query = "INSERT INTO guest";
$query .= "(guest_id, guest_name,";
$query .= " guest_time, guest_message, user_name, imag)";
$query .= " values(0000,'$userses',NULL,'$message','$user_name','$image')";
mysql_pconnect("localhost","cha","")
or die("Unable to connect to SQL server");
mysql_select_db("chaotic") or die("Unable to select database");
mysql_query($query) or die("Insert Failed!");
$update = "SELECT * FROM user where username='$userses'";
$update_result = mysql_query($update) or die (mysql_error());
while ($row = mysql_fetch_assoc($update_result))
{
$postcount = $row['postcount'];
}
$postcount = ++$postcount;
mysql_query("UPDATE user set postcount='$postcount'");
} else {
////////////////////////////////
// If they didn't include all the required fields set a variable
// and keep going.
////////////////////////////////
$notall = 1;
}
}
?>
<HTML>
<HEAD>
<TITLE>Add a Message</TITLE>
</HEAD>
<BODY BGCOLOR="white">
<center>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="113" height="70" id="AutoNumber1">
<tr>
<td width="100" height="1" align="center">
<font face="Verdana" size="1">
<img border="0" src="buttons/monkeywink.gif" width="19" height="19"><br>;)</font></td>
<td width="48" height="1" align="center">
<font face="Verdana" size="1">
<img border="0" src="buttons/monkeybanana.gif" width="19" height="19"><br>:yum:</font></td>
<td width="25" height="1" align="center">
<font face="Verdana" size="1">
<img border="0" src="buttons/monkeypuke.gif" width="19" height="19"><br>:yuck:</font></td>
<td width="34" height="1" align="center">
<font face="Verdana" size="1">
<img border="0" src="buttons/monkeykiss.gif" width="19" height="19"><br>:*</font></td>
<td width="127" height="1" align="center">
<font face="Verdana" size="1">
<img border="0" src="buttons/monkeysurprised.gif" width="19" height="19"><br>:o</font></td>
<td width="37" height="1" align="center">
<font face="Verdana" size="1">
<img border="0" src="buttons/monkeytongue.gif" width="19" height="19"><br>:p</font></td>
<td width="54" height="1" align="center">
<font face="Verdana" size="1">
<img border="0" src="buttons/monkeysuspicious.gif" width="19" height="19"><br>:mm:</font></td>
<td width="123" height="1" align="center">
<font face="Verdana" size="1">
<img border="0" src="buttons/monkeysmile.gif" width="19" height="19"><br>:)</font></td>
</tr>
<tr>
<td width="21" height="1" align="center">
<font face="Verdana" size="1">
<img border="0" src="buttons/monkeyangel.gif" width="19" height="19"><br>;Q</font></td>
<td width="48" height="1" align="center">
<font face="Verdana" size="1">
<img border="0" src="buttons/monkeyshutmouth.gif" width="19" height="19"><br>:I</font></td>
<td width="25" height="1" align="center">
<font face="Verdana" size="1">
<img border="0" src="buttons/monkeyconfused.gif" width="19" height="19"><br>:Z</font></td>
<td width="34" height="1" align="center">
<font face="Verdana" size="1">
<img border="0" src="buttons/monkeycrying.gif" width="19" height="19"><br>x)</font></td>
<td width="127" height="1" align="center">
<font face="Verdana" size="1">
<img border="0" src="buttons/monkeycool.gif" width="19" height="19"><br>:cool:</font></td>
<td width="37" height="1" align="center">
<font face="Verdana" size="1">
<img border="0" src="buttons/monkeybigsmile.gif" width="19" height="19"><br>:))</font></td>
<td width="54" height="1" align="center">
<font face="Verdana" size="1">
<img border="0" src="buttons/monkeysad.gif" width="19" height="19"><br>:(</font></td>
<td width="123" height="1" align="center">
<font face="Verdana" size="1">
<img border="0" src="buttons/monkeyembarrassed.gif" width="19" height="19"><br>;E</font></td>
</tr>
</table>
</center>
<center>
<!-- Let them know that they have to fill in all the blanks -->
<? if ($notall == 1) { ?>
<P><FONT COLOR="red">Please answer all fields</FONT></P>
<? } ?>
<!-- The bits of PHP in the form allow the data that was already input
to be placed back in the form if it is filled out incompletely -->
<?
$userses = $_SESSION['edithtml'];
echo "<FORM METHOD=\"post\" ACTION=\"/community/guest.php?user_name=$user_name\">
<PRE>
Your Name: <INPUT
type=\"text\"
NAME=\"name\"
SIZE=\"20\"
MAXLENGTH=\"50\"
VALUE=\"$userses\">
Enter Message:
<TEXTAREA NAME=\"message\" COLS=\"40\" ROWS=\"8\" WRAP=\"Virtual\">
$message
</TEXTAREA>
<INPUT TYPE=\"submit\" VALUE=\"Tagin\">
</PRE>
</FORM></center>
";
?>
<HR>
<?
////////////////////////////////
// This is where we connect to the database for reading.
////////////////////////////////
mysql_pconnect("localhost","chaotu","")
or die("Unable to connect to SQL server");
mysql_select_db("chaotici_chaotic") or die("Unable to select database");
////////////////////////////////
// This is where we count the number of entries.
////////////////////////////////
$query = "SELECT COUNT(*) FROM guest WHERE user_name='$user_name'";
$numguests = mysql_query($query) or die(mysql_error());
$numguest = mysql_fetch_array($numguests);
?>
<!-- This is where we report the total messages. -->
<?
if ($complete == 1) {
$query = "SELECT * FROM guest WHERE user_name='$user_name' ORDER BY guest_time DESC";
} else {
$query = "SELECT * FROM guest WHERE user_name='$user_name' ORDER BY guest_time DESC LIMIT 20";
}
$guests = mysql_query($query) or die(mysql_error());
while ($guest = mysql_fetch_array($guests))
{
$guest_name = $guest['guest_name'];
$guest_email = $guest['guest_email'];
$guest_time = $guest['guest_time'];
$guest_message = $guest['guest_message'];
$guest_image = $guest['imag'];
$smilie_array = array(
';)' => 'buttons/monkeywink.gif',
':yum:' => 'buttons/monkeybanana.gif',
':yuck:' => 'buttons/monkeypuke.gif',
':*' => 'buttons/monkeykiss.gif',
':o' => 'buttons/monkeysurprised.gif',
':p' => 'buttons/monkeytongue.gif',
':mm:' => 'buttons/monkeysuspicious.gif',
':)' => 'buttons/monkeysmile.gif',
';Q' => 'buttons/monkeyangel.gif',
':I' => 'buttons/monkeyshutmouth.gif',
':Z' => 'buttons/monkeyconfused.gif',
'x)' => 'buttons/monkeycrying.gif',
':cool:' => 'buttons/monkeycool.gif',
':))' => 'buttons/monkeybigsmile.gif',
':(' => 'buttons/monkeysad.gif',
';E' => 'buttons/monkeyembarrassed.gif'
);
foreach ($smilie_array as $smilie => $smilie_file) {
$guest_message = str_replace($smilie, '<img src="/community/' . $smilie_file. '" alt="smilie" />', $guest_message);
}
////////////////////////////////
// The database has a timestamp record type that we can use to show the
// date the guestbook was filled out.
////////////////////////////////
$datefromdb = $guest_time;
$year = substr($datefromdb,0,4);
$mon = substr($datefromdb,4,2);
$day = substr($datefromdb,6,2);
$hour = substr($datefromdb,8,2);
$min = substr($datefromdb,10,2);
$sec = substr($datefromdb,12,2);
$orgdate = date("l F dS, Y h:i A",mktime($hour,$min,$sec,$mon,$day,$year));
echo "<center>";
echo "<TABLE BORDER=\"1\" WIDTH=\"800\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#111111\" style=\"border-collapse: collapse\">
<TR>
<td height=100 rowspan=2>$guest_image</td>
<td height=5 valign=top>Posted By: <a href=viewpage.php?username=$guest_name>$guest_name</a></TD>
<td height=5 valign=top>Date: $orgdate;</TD>
</TR>
<tr>
<td width=800 height=50 colspan=2 valign=top>
$guest_message
</TD>
</TR>
</TABLE>
<BR>";
}
?>
</BODY>
</HTML>
: