Need help with a PHP script for a guestbook

okay I’m trying to make a 2 page PHP guestbook, one page with the submitting form and the other where the messages are displayed. I was having some errors but with some help I was able to fix those. However now after fixing those errors the messages are no longer being put in the database or displayed.

here’s my php script:


<?php //connecting to the Database $connect = mysql_connect("","patben_guestbook","hotmen_1990") or die("Error"); //selecting the table mysql_select_db("patben_guestbookdatabase") or die("Error"); //selecting ALL data $queryget = mysql_query("SELECT * FROM guestbook") or die("Error"); //sort the data while ($row = mysql_fetch_assoc($queryget)) { $id = $row['id']; $date = $row['date']; $name = $row['name']; $email = $row['email']; $song = $row['song']; $part = $row['part']; $comments = $row['comments']; //processing data echo "
Posted by: $name ($email)
Favorite Pat Song: $song
Favorite Part of the Site: $part
"; } if (isset($_POST['submit'])) { $date = date("Y-m-d"); $name = $_POST['name']; $comments = $_POST['comments']; if ($name&&$comments) { $querypost = mysql_query("INSERT INTO guestbook (date, name, email, song, part, comments) VALUES ('','$date','$name','$email','$song','$part','$comments')"); echo "Please wait..."; } else { echo "Please enter your name and comments"; } } ?>[/php]

and my html code for the form:


* Your Name:
Email Address:
Your Favorite Pat Song?:
Your Favorite Part of my Site?:
* Comment:

How do I solve this?

Sponsor our Newsletter | Privacy Policy | Terms of Service