我對php編碼生活相對比較陌生,我需要一些幫助。當我插入數據到我的phpmyadmin帳戶時,它插入了我想要的記錄,但它也插入了一個空白記錄?建議?如果在編碼方面存在任何差距,它們實際上並不存在,這也是本網站的新增內容。將數據插入到phpmyadmin中時插入一個空白記錄
<?php
$host="xxxxx";
$username="xxxxx";
$password="xxxxx";
$db_name="xxxxx";
$tbl_name="LimitlessInventory";
mysql_connect("$host", "$username", "$password")or die("Cannot Connect");
mysql_select_db("$db_name")or die("Cannot Select Database");
$year=$_POST['year'];
$make=$_POST['make'];
$model=$_POST['model'];
$price=$_POST['price'];
$description=$_POST['description'];
$buyme=$_POST['buyme'];
echo "$year";
echo "$make";
echo "$model";
echo "$price";
echo "$description";
echo "$buyme";
$sql="INSERT INTO $tbl_name(year, make, model, price, description, buyme)VALUES('$year', '$make', '$model', '$price', '$description', '$buyme')";
$result=mysql_query($sql);
mysql_close();
?>
<html>
<body>
<title>Limitless Auto</title>
<form action="LimitlessInsert2.php" method="POST">
Year: <input type="text" size="4" maxlength="4" name="year" value="Ex.2012"><br />
Make: <input type="text" size="12" maxlength="12" name="make" value="Ex.Chevrolet"><br />
Model: <input type="text" size="12" maxlength="12" name="model" value="Ex.Corvette"><br />
Price: <input type="text" size="9" maxlength="9" name="price" value="Ex.$15,999.00"><br />
Description: <input type="text" size="75" maxlength="255" name="description" value="Ex.2000 Miles 5.7L V8 Red"><br />
Link: <input type="text" size="255" maxlength="255" name="buyme" value="<a href=http://solemnprophecy.com/DAT201/LimitlessBuyNow.php>Buy_ME!</a>"><br />
<input type="submit" name="submit">
</form>
<a href="http://solemnprophecy.com/DAT201/LimitlessInventory.php">Inventory Page</a>
</body>
</html>
這與phpmyadmin有什麼關係? – Dave
數據庫中的字段和輸入的數據類型可能不匹配。 – 2013-12-19 16:18:07
你剛剛發佈的代碼清楚地顯示了在一個實時網站上的SQL注入,我不知道這是明智的 – Slicedpan