我有一个 html 表单、一个 php 脚本和一个 mysql 数据库我希望表单通过 php 脚本发布到 mysql 数据库。我填写表格并提交,但表格保持不变。我在 Ubuntu 中使用 Lamp 设置。
/var/www/add_review.php
<?
$username="user";
$password="password";
$database="database";
$review=$_POST['review'];
$Cname=$_POST['Cname'];
$picture=$_POST['picture'];
$profile=$_POST['Cprofile'];
$location=$_POST['location'];
$ratingImg=$_POST['ratingImg'];
$rating=$_POST['rating'];
$date=$_POST['date'];
$Creview=$_POST['Creview'];
$link=$_POST['link'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO table VALUES ('$review','$Cname','$picture','$location','$ratingImg','$rating','$date','$Creview','$link')";
mysql_query($query);
if($query)
{
echo "Success!";
}
else
{
die(mysql_error());
}
mysql_close();
echo "Review Added!";
echo "<br />";
echo $review;
echo "<br />";
echo $name;
echo "<br />";
echo $picture;
echo "<br />";
echo $profile;
echo "<br />";
echo $location;
echo "<br />";
echo $ratingImg;
echo "<br />";
echo $rating;
echo "<br />";
echo $date;
echo "<br />";
echo $Creview;
echo "<br />";
echo $link;
?>
/var/www/add_review.html
<h1>Add A Drink</h1>
<form action="add_review.php" method="post">
<p>Review # <input type="text" name="review"><br></p>
<p>UserName <input type="text" name="Cname"><br></p>
<p>Picture URL <input type="text" name = "picture"><br></p>
<p>Users Profile URL <input type="text" name = "Cprofile"><br></p>
<p>Location <input type="text" name = "location"><br></p>
<p>Star URL <input type="text" name = "ratingImg"><br></p>
<p>Star Value <input type="text" name = "rating"><br></p>
<p>Date(MMDDYYYY) <input type="text" name = "date"><br></p>
<p>Users Review<br> <textarea name="Creview"></textarea><br></p>
<p>Review Link <input type="text" name = "link"><br></p>
<input type="submit" value="Submit">
</form>
MYSQL 表
+-----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| review | int(11) | YES | | NULL | |
| Cname | varchar(20) | YES | | NULL | |
| picture | text | YES | | NULL | |
| Cprofile | text | YES | | NULL | |
| location | varchar(30) | YES | | NULL | |
| ratingImg | text | YES | | NULL | |
| rating | float | YES | | NULL | |
| date | int(11) | YES | | NULL | |
| Creview | text | YES | | NULL | |
| link | text | YES | | NULL | |
+-----------+-------------+------+-----+---------+-------+
我无法弄清楚我做错了什么!请帮忙。