يك مشكل ساده در بانك اطلاعاتي
سلام
من يك بانك اطلاعاتي با نام "publisher" دارم كه جداول :isbn-author-title-price-pagr " داره
حالا يه مشكل
وقتي از طريق بانك اطلاعاتي اطلاعات را وارد ميكنم اطلاعات توي list.php نمايش داده ميشن
ولي وقتي اطلاعات را از طريق send.html ارسال ميكنم هيچي ثبت نميشه
ليست كدهاي form.html:
[HTML]<html>
<body>
<form method = "post" action = "book.php">
<table border = "1">
<tr>
<td><b> ISBN</b></td>
<td><input type = "text" name = "isbn" size = "13"> </td>
</tr>
<tr>
<td><b> Author</b></td>
<td><input type = "text" name = "auther" size = "20"> </td>
</tr>
<tr>
<td><b> Title</b></td>
<td><input type = "text" name = "title" size = "25"> </td>
</tr>
<tr>
<td><b> Price</b></td>
<td><input type = "text" name = "price" size = "5"> </td>
</tr>
<tr>
<td><b> Page</b></td>
<td><input type = "text" name = "page" size = "5"> </td>
</tr>
<tr>
<td width = "20"></td>
<td><b> <input type = "submit" name = "submit" value = "Submit"></b></td
</tr>
</table>
</body>
</html>
[/HTML]
ليست كدهاي book.php:
[HTML]<?php
//retrieve from variables
$isbn = $_POST['isbn'];
$auther = $_POST['auther'];
$title = $_POST['title'];
$price = $_POST['price'];
$page = $_POST['page'];
if (strlen($isbn) == 0 or strlen($auther) == 0)
{
echo"go back and fill all field";
exit;
}
//connect to mysql server
$db = mysql_connect("localhost", "root", "");
if(!$db)
{
echo " Error : cannot open connection.";
exit;
}
mysql_select_db('publisher');
$query = "insert into books
(isbn, auther, price, page)values
('".$isbn."', '".$auther."', '".$title."', '".$price."', '".$page."')";
$result = mysql_query($query);
if($result)
echo mysql_effected_rows().'<b>book inserted into database.</b>';
mysql_close($db);
?>[/HTML]
ليست كدهايlist.php:
[HTML]<html>
<body>
<div align="center">
<table border = "1" height="100" >
<tr>
<th width="27"> isbn</th>
<th> Auther</th>
<th> Title </th>
<th> Price </th>
<th> page </th>
</tr>
<?php
$db = mysql_connect("localhost", "root", "");
if(!$db)
{
echo 'Error : Cannot connect to MySQL server.';
exit;
}
mysql_select_db('publisher');
$query = "select * from books";
$result = mysql_query($query);
if(!$result)
{
echo "Query not executed.";
exit;
}
$num = mysql_num_rows($result);
for($i = 0; $i < $num; $i ++)
{
$row = mysql_fetch_row($result);
echo '<tr>';
echo "<td><b> $row[0]</b> </td>";
echo "<td><b> $row[1]</b> </td>";
echo "<td><b> $row[2]</b> </td>";
echo "<td><b> $row[4]</b> </td>";
echo "<td><b> $row[3]</b> </td>";
echo '</tr>';
}
mysql_close();
?>
</table>
</div>
</body>
</html>[/HTML]
حالا شما بگيد مشكل از كجاست كه اطلاعات به بانك اطلاعاتي ارسال نميشن؟