i currently have a guestbook script that i wrote from a similar one that i liked. now i am still trying to learn php, so bear with me here. I will try to make this as clear as possible. i have found a way to bring the original text to and edit box if you try to edit the comment, but i cant get it to replace the original text. instead, it posts it right below the original text like a follow up or something. i need it to replace the original text. is someone has a script that i can use to do this, i will give full credit on my site if i use the script.
here is what i have for now in my index.php file
--------------------------------------
if you can find the error in that, i would greatly appreciate it. you will notice in the code that i do have it displaying the textbox with the original message. the top one will be changed to not do that anymore and will be a textbox to have followup responces written by the me to anyones posting, but the second box will need to display the original text so that it can be edited. second though, you can remove the first text box from the code, and keep the second since this is going to be a script now being used for a guestbook anymore. it will be used for me to post messages directly from my site and displayed on a recent news link page for my site. please help. thanks in advance
here is what i have for now in my index.php file
PHP:
<?PHP
// [url]www.methodcomptech.com[/url]
include "functions.php";
if ($sss == 1)
{
$sm = array *****smily code goes in here, dont worry about this part*****;
$num_smiley = 73;
for ($nc = 1;$nc <= $num_smiley;$nc++)
$num[] = "<img src=y_emo/$nc.gif>";
}
$num_entry=mysql_numrows($gb);
$epp = $def_epp;
if (isset($_GET['epp']) and ($_GET['epp'] != ""))
$epp = $_GET['epp'];
$pg = 1;
if (isset($_GET['pg']) and ($_GET['pg'] != ""))
$pg = $_GET['pg'];
$tp = ceil($num_entry/$epp);
$start = ($pg-1) * $epp;
$end = $start + $epp;
echo "<html><head><title>$title</title></head><body text=#000000 link=gray alink=gray vlink=gray bgcolor=white><font size=1>";
if ($center != 0)
echo "<center>";
echo "<table width=$width cellpadding=0 cellspacing=0 border=0><tr><td width=1%><img src=ipei_imgs/blank.gif width=1 height=1></td><td width=96% valign=bottom align=right><font face=arial size=1 color=gray>Page: ";
echo "<a href=index.php?pg=1&epp=$epp><<</a> | ";
for ($a=$pg-4;$a < $pg;$a++)
{
if (($a >= 1) and ($a <= $tp))
echo "<a href=index.php?pg=$a&epp=$epp>$a</a> | ";
}
echo "<b><font size=+1>$pg</font></b>";
for ($b=$pg+1;$b <= $pg+4;$b++)
{
if (($b >= 1) and ($b <= $tp))
echo " | <a href=index.php?pg=$b&epp=$epp>$b</a>";
}
echo " | <a href=index.php?pg=$tp&epp=$epp>>></a>";
echo " of $tp pages.<br><font face=arial size=4 color=gray><a href=index.php?a=view>v<b>i</b>ew</a> / <a href=index.php?a=sign>s<b>i</b>gn</a></font></font></td><td width=3%><img src=ipei_imgs/blank.gif width=1 height=1></td></tr></table><br><br>";
if ($_GET['a'] == "smilies")
{
echo "<font size=1 face=arial color=gray>Emoticons are © Yahoo!<br>note: not all smilie codes are exactly same as on Yahoo Messenger</font><br><br><table border=1>";
for ($i=0;$i < $num_smiley;$i++)
{
echo "<tr><td>$sm[$i]</td><td>$num[$i]</td></tr>";
}
echo "</table>";
}
else if ($_GET['a'] == "process_delete")
{
if ($_POST[password] == $pw)
{
$DQuery = "DELETE FROM `$table` WHERE `entrynum` = $_POST[e]";
mysql_query($DQuery);
echo "<font size=2 face=arial>Entry $_POST[e] Deleted.<br><br></font>";
}
else
echo "<font size=2 face=arial>Invalid Password<br><br></font>";
}
else if ($_GET['a'] == "process_comment")
{
if ($_POST[password] == $pw)
{
$cmttime = date("Y-m-d H:i:s");
$querya="UPDATE `$table` SET `comment` = '$_POST[comment]',`comment_date` = '$cmttime' WHERE `entrynum` = '$_POST[e]'";
mysql_query($querya);
echo "<font size=2 face=arial>Comment added for entry $_POST[e].<br><br></font>";
}
else
echo "<font size=2 face=arial>Invalid Password<br><br></font>";
}
else if ($_GET['a'] == "edit")
{
if ($_POST[password] == $pw)
{
$query="SELECT * FROM `$table` WHERE 1 AND `entrynum` = $_POST[e]";
$entryfile=mysql_query($query);
$tip = mysql_result($entryfile,0,"ip");
$tisp = mysql_result($entryfile,0,"res_ip");
$original_cmt = mysql_result($entryfile,0,"msg");
echo "<font size=1 color=gray face=arial>Edit Original Message:<br></font><form action=index.php?a=process_comment method=POST><input type=hidden name=\"password\" value=\"$_POST[password]\"><input type=hidden name=\"e\" value=\"$_POST[e]\"><TEXTAREA name=\"comment\" rows=12 cols=45>$original_cmt</TEXTAREA><br><input type=submit name=submit value=\"Edit Comment\" mysql_query($DQuery)></form><hr width=$width><br></font>";
//////////////////////
echo "<font size=1 color=gray face=arial>Edit Original Message:<br></font><form action=index.php?a=process_comment method=POST><input type=hidden name=\"password\" value=\"$_POST[password]\"><input type=hidden name=\"e\" value=\"$_POST[e]\"><table cellspacing=3 cellpadding=3 border=0>
<tr><td><TEXTAREA name=\"msg\" rows=12 cols=45>$original_cmt</TEXTAREA></td></tr>
</table><br><input type=submit name=submit value=\"Edit Comment\"></form><br>";
//////////////////////
echo "<font size=2 face=arial>IP: $tip<br>Resolved IP: $tisp<br>";
echo "<font size=2 face=arial><br>Original Message:<br>";
displayEntry(mysql_result($entryfile,0,"name"),mysql_result($entryfile,0,"msg"),mysql_result($entryfile,0,"comment"),mysql_result($entryfile,0,"email"),mysql_result($entryfile,0,"homepage"),convert_datetime(mysql_result($entryfile,0,"date"), "F j Y"),1,mysql_result($entryfile,0,"entrynum"));
echo "<br><hr width=$width><font size=1 color=red face=arial>Delete:<br></font><form action=index.php?a=process_delete method=POST><input type=hidden name=\"password\" value=\"$_POST[password]\"><input type=hidden name=\"e\" value=\"$_POST[e]\"><input type=submit name=submit value=\"Delete entry #$_POST[e], CANNOT BE UNDONE\"></form>";
}
else
echo "<font size=2 face=arial>Invalid Password<br><br></font>";
}
else if ($_GET['a'] == "login")
{
$form = "<br><form action=index.php?a=edit method=POST><table cellspacing=3 cellpadding=3 border=0>
<tr><td valign=top align=right><font size=2 face=\"$font\" color=$fcolor>password</font></td><td><input type=password name=\"password\" size=26><input type=hidden name=\"e\" value=\"$_GET[e]\"></td></tr>
<tr><td> </td><td><input type=submit name=submit value=\"Login to edit entry #$_GET[e]\"></td></tr>
</table></form><br>";
echo $form;
}
else if ($_GET['a'] == "process")
{
if (($_POST[name] == "") or ($_POST[msg] == ""))
echo "<font size=2 face=arial>Missing Field(s): please input a name and a message<br><br></font>";
else {
$entrytime = date("Y-m-d H:i:s");
$userIP = getenv("REMOTE_ADDR");
$userISP = gethostbyaddr($userIP);
$in_query = "INSERT INTO `$table` VALUES ('','$_POST[name]','$_POST[email]','$_POST[homepage]','','$_POST[msg]','$entrytime','','','$userIP','$userISP','1')";
mysql_query($in_query);
echo "<font size=2 face=arial>Thank you for posting $_POST[name]!<br><br></font>";
}
}
else if ($_GET['a'] == "sign")
{
$form = "<br><form action=index.php?a=process method=POST><table cellspacing=3 cellpadding=3 border=0>
<tr><td valign=top align=right><font size=2 face=\"$font\" color=$fcolor>name</font></td><td><input type=text name=\"name\" size=26></td></tr>
<tr><td valign=top align=right><font size=2 face=\"$font\" color=$fcolor>email</font></td><td><input type=text name=\"email\" size=26></td></tr>
<tr><td valign=top align=right><font size=2 face=\"$font\" color=$fcolor>homepage</font></td><td><input type=text name=\"homepage\" value=\"http://\" size=26></td></tr>
<tr><td valign=top align=right><font size=2 face=\"$font\" color=$fcolor>message</font></td><td><TEXTAREA name=\"msg\" rows=6 cols=30></TEXTAREA></td></tr>
<tr><td> </td><td><input type=submit name=submit value=Post></td></tr></table></form>";
if ($sss == 1)
$form = $form . "<center><a href=index.php?a=smilies target=_blank>smilies help</a></center><br>";
displayEntry("Sign Guestbook",$form,"",NULL,NULL,NULL,0,NULL);
}
else if ($num_entry == 0)
{
echo "<font size=2 face=arial>The guestbook is empty.<br><br></font>";
}
else
{
for ($c=$start;$c < $end;$c++)
{
if (($c >= 0) and ($c < $num_entry))
{
displayEntry(mysql_result($gb,$c,"name"),mysql_result($gb,$c,"msg"),mysql_result($gb,$c,"comment"),mysql_result($gb,$c,"email"),mysql_result($gb,$c,"homepage"),convert_datetime(mysql_result($gb,$c,"date"), "F j Y"),1,mysql_result($gb,$c,"entrynum"));
}
}
}
cleanup();
echo "</center><br><br></font></body><comment><!-- Method Comptech Technologies Guestbook - www.methodcomptech.com | emoticons are copyright by Yahoo! --></comment></html>";
?>
if you can find the error in that, i would greatly appreciate it. you will notice in the code that i do have it displaying the textbox with the original message. the top one will be changed to not do that anymore and will be a textbox to have followup responces written by the me to anyones posting, but the second box will need to display the original text so that it can be edited. second though, you can remove the first text box from the code, and keep the second since this is going to be a script now being used for a guestbook anymore. it will be used for me to post messages directly from my site and displayed on a recent news link page for my site. please help. thanks in advance
Last edited: