Jump to content


Photo

HELP


  • Please log in to reply
2 replies to this topic

#1 undertaker16

undertaker16
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 25 March 2006 - 08:33 PM

HELP!!!

I have a very simple php and mysql app and it will work, but when i Sign my own guest book and the i go to admin.php it will pull the first entry out and if there are more than one, it will keep the same one it pulled out in the first place. Also, when i delete the first entry it will redirect me back to admin.php and it will repeat.
WHY????????

If you need the code please reply.

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 25 March 2006 - 09:22 PM

Please post your code here. Or if is a lot of code, post the relevant snippets.

Ken

#3 undertaker16

undertaker16
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 27 March 2006 - 04:29 AM

code for aheader.php:
CODE

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN">
<html>

<head>
<title>GuestBook Administration</title>
<script language="Javascript">
function delEntry(id,name)
{
if(confirm("Are you sure you want to delete " + name + "\'s entry?"))
{
window.location.href='delete.php?id=' + id;
}
}
</script>
</head>
<body>



Code for admin.php:
CODE

<?php

include("config.php");

include("$header");

$result=mysql_query ("SELECT id,name,message FROM `gbook` WHERE id>=1 ORDER BY id ");
if ($row=mysql_fetch_array($result)) {
print("<h2><center><p align=\"center\">All entries are shown below. Click the appropriate links according to which action you'd like to perform.</p></center></h2>");
$id = $row[id];
$name = $row[name];
$msg = $row[message];
echo "<table><tr bgcolor=\"696969\" text=\"#ffffff\"><th>Action</th><th>Name</th><th>Message</th></tr>";
do {
?>

<tr><td><a href="java script:delEntry('<?php echo $id; ?>','<?php echo $name; ?>');">Delete</a></td>
<td><?php echo $name; ?></td>
<td><?php echo $msg; ?></td>
</tr>

<?

}

while($row = mysql_fetch_array($result));

}

else {

print("<h2><center><p align=\"center\">There are no entries in this Guestbook.</p></center></h2>");

}

echo "</table><br /><br />";

//include("$footer");

?>


Code for add.php:
CODE

<?php
require("config.php");

$name = $_POST["name"];
$message = $_POST["message"];

$query = "INSERT INTO `gbook` VALUES ('', '$name', '$message')";

mysql_query($query);

print("<meta http-equiv=\"refresh\" content=\"5;url=index.php\"");

print("<center><h1><p align=\"center\">Thank you, $name, for your message.</p>");

print("<p align=\"center\">You will be redirected back within five (5) seconds ...</p></h1></center>");


					
					




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users