First thing i have to say is I'm a student so my English is not very good.
Second thing is that my guestbook is working 100% but there is an error line which is a pain in the neck to me.
I make my guestbook by following this tutorial in Youtube.
http://www.youtube.com/view_play_list?p ... 1E7CD0977E
Everything seems to be alrigth, my guestbook works properly but as i said there is a error line which is a nightmare.
Here is my code:
Code: Select all
<?
//PHP Guestbook using mySQL database
echo "<h1>Guestbook</h1><hr>";
//connect to the database
$connect =mysql_connect("localhost","root","usbw")or die("Error connecting to db");
//select table
mysql_select_db("prueba")or die ("Error selecting db");
//use query to get ALL data
$queryget = mysql_query("SELECT * FROM guestbook ORDER BY id ASC") or die("Error with query");
//creo q en la linea de codigo de arriba donde pone ASC significa ascendente
$querygetrownum = mysql_num_rows ($queryget);
if ($querygetrownum==0)
echo"No posts have been made yet. Be the first";
while ($row = mysql_fetch_assoc($queryget))
{
// get row data and store in vars
$id = $row['id'];
$name = $row['name'];
$email = $row['email'];
$message = $row['message'];
$date = $row['date'];
$id = $row['id'];
$time = $row['time'];
if ($id%2)
$bgcolor = '#FFFFFF';
else
$bgcolor = '#e1e1e1';
//show data to user
echo "
<table bgcolor='$bgcolor'>
<tr>
<td>
<b>Posted by $name ($email) on $date at $time </b>
</td>
</tr>
<tr>
<td>
".nl2br(strip_tags($message))."
</td>
</tr>
</table>
"; //este ultimo punto y coma lo e puesto por mi cuenta ya que la linea n51 daba error
}
echo"<hr>";
if ($_POST ['submit'])
{
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$date = date("Y-m-d");
$time = date("H:i:s");
if($name&&$email&&$message)
{
$querypost = mysql_query("INSERT INTO guestbook VALUES ('','$name','$email','$message','$date','$time')");
echo "Please wait ...<meta http-equiv='refresh' content='2'>";
}
else
echo "Please fill out all fields!";
}
echo"
<form action='index.php' method='POST'>
<table width='100%'>
<tr>
<td width='18% valign='top'>
Your name:
</td>
<td>
<input type='text' name='name' maxlength='25'>
</td>
</tr>
<tr>
<td>
Your email:
</td>
<td>
<input type='text' name='email' maxlength='35'>
</td>
</tr>
<tr>
<td valign='top'>
Your message:
</td>
<td>
<textarea cols='20' rows='2' name='message' maxlength='250'></textarea>
<p>
<input type='submit' name='submit' value='Post'>
</td>
</tr>
</table>
</form>
";
?>Notice: Undefined index: submit in E:\PortableApps\UsbWebserver\Root\pagina\index.php on line 55
This is the line error or line 55
if ($_POST ['submit'])
Is there anything wrong in that line?
Please i'll be very grateful if you could tell me.