Parašė auris999· 2009 Bir. 28 20:06:25
#3
Čia vistiek kažkas negerai... man neišmeta info iš guestbook table... bet net nerodo ar as prisijungiu prie db ar ne... neleidžia ir postint. Padekit naujokėliui.
<?php
echo "<h1>Guestbook</h1><hr>";
//connect to the database
$connect = mysql_connect("mysql3.bendras.com","login","pass") or die("Error connecting to db");
//select table
mysql_select_db("phpacademy") or die("Error selecting db");
//use query to get ALL data
$queryget = mysql_query("SELECT * FROM guestbook") or die("Error with query");
while ($row = mysql_fetch_assoc($querryget))
{
// get row data and store in variables
$id = $row['id'];
$name = $row['name'];
$email = $row['email'];
$message = $row['message'];
$date = $row['date'];
$time = $row['time'];
// show data to user
echo "
<table>
<tr>
<td>
<b>Posted by $name ($email) on $date and $time</b>
</td>
</tr>
<tr>
<td>
".n12br(strip_tags($message))."
</td>
</tr>
</table>
";
}
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='aindex.php' method='POST'>
<table width='100%'>
<tr>
<td width='17%' valign='top'>
Your name:
</td>
<td>
<input type='text' name='name' maxlenght='25'>
</td>
</tr>
<tr>
<td valign='top'>
Your email:
</td>
<td>
<input type='text' name='email' maxlenght='35'>
</td>
</tr>
<tr>
<td valign='top'>
Your message:
</td>
<td>
<textarea cols='20' rows='2' name='message' maxlenght='250'></textarea>
<p>
<input type='submit' value='Post'>
</td>
</tr>
</table>
</form>
";
?>