我想使用php将值保存在数据库中,我没有错误,但是数据库是空的,它没有保存数据。
我放了 if 语句来检查之前保存的值是否
请检查我的代码
请帮我
<?php
$submit = $_POST['submit'];
$sid = strip_tags($_POST['sid']);
$Desc = strip_tags($_POST['Desc']);
if ($submit) {
// open data base
$connet = mysql_connect("localhost", "root", "hahaha1");
mysql_select_db("senior");
$sensorcheck = mysql_query("SELECT sid FROM availblesensors WHERE sid='$sid'");
$count = mysql_num_rows($sensorcheck);
if ($count != 0) {
die("You add this Sensor ID before!");
}
if ($sid && $Desc) {
mysql_query("INSERT INTO availblesensors ('$sid','$Desc')");
// success
die("You have add new sensor Successfully !! <a href='admin.php'>click here to return to admin page</a> or Here to
<a href='gotoaddsensor.php'>add new sensor</a>");
} else {
echo "<h3><font color='red'>Please fill in <b>all</b> feilds!</font></h3>";
}
}
?>
<form action="gotoaddsensor.php" method="post" class="one">
<div class="info">
<center><div>Please add availble sensors with a few description of it if you need</div></center><br/>
</div>
<div><b><label for="sid">Sensor ID</label>:</b>
<input name="sid" value="" id="sid" type="text" size="15"/> </div>
<br />
<div><b><label for="password">Description</label>:</b>
<input name="Desc" value="" id="Desc" type="text" size="40"/></div>
<br />
<div id="login-button">
<input name="submit" type="submit" value="submit" />
<input type="reset" value="clear" />
</div>
</form>