mrmodest Posted July 2, 2012 Share Posted July 2, 2012 Alright, I am trying to learn some PHP so I have been following a tutorial on how to make a simple guestbook page for my website. The problem is, the post button I coded into the page is not appearing and the area that I want displaying the current posts is appearing in the message text area where you actually are supposed to write posts. Everything is working properly with the database though which is a feat on my part. I must have a problem with a quotation somewhere but I have been looking for hours for my error. It is not a lot of code but I am not well experienced with this language. Everything looks correct until the message area underneath the other 2 text areas. <?php error_reporting (E_ALL ^ E_NOTICE); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xht <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Guestbook - Index</title> </head> <body> <?php mysql_connect("xxx","xxx", "xxx") OR DIE ('Unable to connect to database! Please try again later.'); mysql_select_db("xxx"); echo "<h2>Post to the Guestbook</h2>"; if ($_POST['postbtn']){ $name = striptags($_POST['name']); $email = striptags($_POST['email']); $message = striptags($_POST['message']); if ($name && $email && $message){ $time = date("h:i A"); $date = date("F d, Y"); $ip = $_SERVER['REMOTE_ADDR']; // add to the database mysql_query("INSERT INTO guestbook VALUES ( '', '$name', '$email', '$message', '$time', '$date', '$ip' )"); echo "Post submitted!"; } else echo "All information is required for posting."; } echo "<form action='./guestbook.php' method='post'> <table> <tr> <td>Name:</td> <td><input type='text' name='name' style='width: 200px;' /></td> </tr> <tr> <td>Email:</td> <td><input type='text' name='email' style='width: 200px;' /></td> </tr> <tr> <td>Message:</td> <td><textarea name='message' style='width: 200px; height: 100px;' /></td> </tr> <tr> <td></td> <td><input type='submit' name='postbtn' value='Post' /></td> </tr> </table> </form>"; // DISPLAY echo "<h2>Current Posts</h2>"; $query = mysql_query("SELECT * FROM guestbook ORDER BY id DESC"); // get most recent post $numrows = mysql_num_rows($query); // how much data has been found if ($numrows > 0) { // if there are posts in the database echo "</ hr>"; // top horizontal line while ( $row = mysql_fetch_assoc($query) ) { $id = $row['id']; // get id out of the row variable for particular query $name = $row['name']; $email = $row['email']; $message = $row['message']; $time = $row['time']; $date = $row['date']; $ip = $row['ip']; $message = nl2br($message); // for breaking if new line echo "<div> By <b>$name</b> at <b>$time</b> on <b>$date</b><hr /> $message </div> <hr />"; } } else echo "No posts were found."; mysql_close(); ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/265119-newbie-help-with-guestbook/ Share on other sites More sharing options...
Barand Posted July 2, 2012 Share Posted July 2, 2012 <textarea> needs a </textarea> closing tag <td><textarea name='message' style='width: 200px; height: 100px;' >TEXT GOES HERE</textarea></td> Link to comment https://forums.phpfreaks.com/topic/265119-newbie-help-with-guestbook/#findComment-1358620 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.