QUOTE(genie19 @ Mar 28 2008, 06:24 PM)

Hi thanks a lot for helping me but like i said i am a complete noob at coding and php scripts. i know how to set up the table so i will do that. do i also need another table with members in it like you said so i can have admin in there? Also what shud i name my database so this code will work ?
and i dont really understand this bit sorry
"You can put it anywhere you want the form to be. But remember to change the action="/shoutbox.php" near the bottom of the code at the start of the input form, or else it wont send the info to the top of the page. and remember to put a copy of the require(db_connect.php); ABOVE the <head> tag." how many pages do i need to make or do i put this whole script into one page? thanks again and hope to hear from you soon
hi just to let you know what i have tried. ok i have a database set up as genie19_bouncy inside i have 2 tables. the first is shoutbox which is set up as follows
Field Name Type Null Default Extra
username varchar(50) No
message varchar(50) No
second table is members which is set up as follows
Field Name Type Null Default Extra
Id int(11) No auto_increment primary key
name varchar(50) No
i then made a file called db_connect and used the following script (dont know if its right)
<html>
<head>
<title>Test PHP Page</title>
</head>
<body>
<?php
mysql_connect ("localhost", "MY USERNAME WAS HERE",
"MY PASSWROD WAS HEREl") or die ('I cannot connect to the
database because: ' . mysql_error());
mysql_select_db ("genie19_bouncy");
?>
</body>
</html>
i then made a new page called shoutbox.php and used the following script (trying to do what you said in this post)
<html>
<head>
<title>Test PHP Page</title>
</head>
<body>
<?php
require 'db_connect.php';
$username = $_POST['username'];
$message = $_POST['message'];
$error = '0';
$row = mysql_query ("SELECT * FROM members");
$myrow = mysql_fetch_array($row);
admin = $myrow['username'];
if($admin == "admin")
{
$query = "SELECT username, message FROM shoutbox";
$sqlshouts = mysql_query($query);
if(!$sqlshouts)
{
?>
<p><?php print '$query: '.$query.mysql_error();?></p>
<?php
}
else if (!mysql_num_rows($sqlshouts) )
{
?>
<center><p><b>There are no Shouts.</b></p></center>
<?php
}
else
{
?>
<table width="80%">
<?php
while($shouts = mysql_fetch_array($sqlshouts))
{
$username = $shouts['username'];
$message = $shouts['message'];
?>
<center>
<tr>
<td width="50px" valign="top"><p><b><u>Sender:<?php echo $sender; ?></u></b></p></td>
</tr>
<tr>
<td width="50px" valign="top"><p><b><u>Shout:</u></b></p></td>
</tr>
<tr>
<td width="100px" valign="top"><p><?php echo $message; ?></p><br><br></td>
</tr>
</center>
<?php
}
?>
</table>
<?php
}
}
else
{
if(!$username AND !$message)
{
?>
<p><b>Make a Shout</b></p>
<br>
<?php
}
else
{
if (!$username)
{
$error = 'You must enter a your name!';
}
if (!$message)
{
$error = 'You must enter a shout';
}
if($error != '0')
{
echo "<p>$error</p><br>";
}
else
{
mysql_query("INSERT INTO shoutbox (username, message) VALUES('$username', '$message')") or die (mysql_error());
echo "<p><b>You have successfully posted your Shout!</b></p><br>";
}
}
?>
<center>
<form name="send" method="post" action="/shoutbox.php"> <?php
Your Name:
<input name="username" type="text" id="username" value="<?php echo $username; ?>">
<br><br>
Your Shout:
<textarea name="message" type="text" id="message" value="" cols="30" rows="5"></textarea>
<br>
<input type="submit" name="Submit" value="Submit">
</center>
</form>
<?php
}
?>
</body>
</html>
I then uploaded both the shoutbox.php and the db_connect page but when i click on shoutbox.php to open in the webbrowser i just get an empty page the same happens when i click db_connect.
thanks for your time n help i hope you can figure out what im doing wrong.