OK, I am coding a shoutbox, if there is nothing in the databse it says so, and if there is, it shows it with a form underneath to reply!
BUT it shows nothing on the page when I try see it
PHP Code:
<?
$date = "blah";
// Make the form
$form = "
<form action=\"$_SERVER[PHP_SELF]\" method=\"post\">
Your name:<br>
<input name=\"name\" id=\"name\">
<br><br>
<input name=\"date\" id=\"date\" value=\"$date\" type=\"hidden\">
Your message:<br>
<textarea name=\"message\" cols=\"27\" rows=\"8\"></textarea>
<br><br>
<input type=\"submit\" name=\"submit\" value=\"Shout it out!\">
";
// Connect to the DB
include("connect.php");
// Select the database
$result=mysql_query("SELECT * FROM shoutbox");
$num = mysql_num_rows($result);
while($row=mysql_fetch_array($result)) {
// Pull out the needed information
$id = $row['id'];
$name = $row['name'];
$email = $row['email'];
$message = $row['message'];
$date = $row['date'];
// Get rid of the dirty slashes!
$message = stripslashes($message);
// If the form is submitted
if (!isset($submit)) {
// Retrieve the information
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$date = $_POST['date'];
// Check the information
if(!$name) {
exit("You have not entered a valid name, please enter a name!");
}
if(!$email) {
exit("You have not entered an E-Mail, please enter an email!");
}
// Add the slashes so quotes work
$message = addslashes($message);
// Insert the information
$query = "INSERT INTO shoutbox VALUES ('','$name','$message','$email','$date')";
mysql_query($query) or die("Could not insert information because: ".mysql_error());
} else {
// Show the shouts!
if($num == "0") {
echo("Sorry, there has been no shouts yet. Check back some other time");
} else {
echo("<a href=\"mailto:".$email."\">$name - $date</a>");
echo("<br>");
echo("$message");
echo("<br><br>");
echo("$form");
}
}
mysql_close();
}
?>
Anyone help?
Last edited by feraira; 06-15-2005 at 09:02 AM..
|