Я хочу поблагодарить вас заранее за помощь в решении моей связанной проблемы. Дело в том, что моя гостевая книга получает данные в базу данных, поэтому она подключается, но когда я нахожу данные, данные поступают в базу данных, но не отображаются. Я не уверен, что это может быть конфликт версий. Я смотрел YouTube в создании этой гостевой книги, но не знаю, какую версию создал тот, кто создал гостевую книгу. Все работает, кроме отображения сообщения. Мне было интересно, могли бы вы, ребята, помочь мне с этим, и я отправлю код ниже.Моя гостевая книга не отображает сообщения, которые я вводил
<?php error_reporting(E_ALL^E_NOTICE^E_DEPRECATED); ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title of the document</title>
</head>
<body>
<?php
// connect to the database
mysql_connect('localhost', 'root', '');
mysql_select_db('tutorials');
/* * ************************************************* */
// form and add stuff area
echo "<h3> Enter posts to GuestBook </h3>";
if ($_POST['postbtn']) {
$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['email']);
$message = strip_tags($_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 "Your post has been added.";
} else {
echo "You did not enter in all the required information";
}
}
echo "<form action = './guestbook.php' method = 'post'>
<table>
<tr>
<td>Name:</td>
<td><input type = 'text' name = 'name' style = 'width: 300px;' /></td>
</tr>
<tr>
<td>Email:</td>
<td><input type = 'text' name = 'email' style = 'width: 300px;' /></td>
</tr>
<tr>
<td>Message:</td>
<td><textarea name = 'message' style = 'width: 300px; height: 300px;'></textarea></td>
</tr>
<tr>
<td></td>
<td><input type = 'submit' name = 'postbtn' value = 'Post' /></td>
</tr>
</table>
</form>";
/* * ************************************************ */
//display stuff area
echo "<h3> Current Posts </h3>";
$query = mysql_query("SELECT * FROM guestbook ORDER BY id DESC");
$numrows = mysql_num_rows($query);
if ($numrows > 0) {
echo "<hr />"; //echoing out the top horizontal line
while ($rows = mysql_fetch_assoc($query)) {
$id = $row['id'];
$name = $row['name'];
$email = $row['email'];
$message = $row['message'];
$time = $row['time'];
$date = $row['date'];
$ip = $row['ip'];
//nl2br new line to break function
$message = nl2br("message");
echo "<div>
By <b>$name</b> - at <b>$time</b> on <b>$date </b><br />
$message
</div> <hr />";
}
} else {
echo "No posts were found.";
}
mysql_close();
?>
</body>
</html>
textarea box и sql query work, просто не знаю, почему он не отображается. –
вот мой pastebin, где отображается весь код. http://pastebin.com/TpG0L8hy –
Помогите кому-нибудь –