我在这里愚蠢,因为我不知道是什么搞砸了我的节目。
我意外地删除了我的数据库,所有其他细节都消失了,但我马上从头开始创建了一个数据库。在我完成了一张桌子(工作正常)后,我遇到了这个问题
//Selection of DB
mysql_select_db("isladb", $con);
//checking of fields
$cusname =$_POST[cus_name];
$cotnum =$_POST[cott_num];
$eq_name = $_POST[eq_name];
if($cusname == "" || $cotnum== ""|| $eq_name== ""){
echo "<script>alert(\"Please complete the form before submiting.\");</script>";
echo "<script>window.history.back();</script>";
}
elseif(is_numeric($cusname)){
echo "<script>alert(\"Enter a valid name.\");</script>";
echo "<script>window.history.back();</script>";
}
elseif($cotnum>20){
echo "<script>alert(\"Exceeded number of cottages\");</script>";
echo "<script>window.history.back();</script>";
}
else {
//getdate
date_default_timezone_set('Asia/Hong_Kong');
$date=date('y.m.d H:i:s');
//calculation of timeout
$inc = 8 * 3600;
$timeout = date('y.m.d H:i:s A', time()+ $inc);
//calculation of total cost
if ($eq_name == "Inner Tube") {
$cost = 200;
} elseif ($eq_name == "Floating Cottage") {
$cost = 500;
}
$hours = 8;
$total_hours = $hours + $ext;
$ext = 0;
$total_cost = $cost + $ext;
mysql_query("INSERT INTO equiptable (cus_ID, cus_name, time_in, total_hours,
total_cost, eq_name, time_out, cott_num)
VALUES (NULL, '$cusname', '$date', '$total_hours', '$total_cost', '$eq_name',
'$timeout', '$cotnum')");
mysql_close($con);
}
这是它之前的形式
<form action="handler_eq.php" method="post" style="text-decoration:none; color:000;">
Customer Name: <input type="text" name="cus_name" value=""/></br></br>
Cottage Number:
<?php
$con=mysql_connect("localhost","root","");
if(!$con)
{die('Error'.mysql_error());}
mysql_select_db("isladb",$con);
$result = mysql_query("SELECT * FROM cottagetable");
echo"<SELECT name='cott_num' >";
echo"<option>Select </option>\n";
while ($row = mysql_fetch_array($result)){
$cotnum = $row["cott_num"];
$vacancy = $row["vacancy"];
if($vacancy=="Occupied")
{ echo " <option value=\"$cotnum\">$cotnum</option>";}
else{};
}echo " </select> ";
?>
</SELECT>
Equipment Name:
</br>
<input style="display:inline; width:0px;" name="eq_name" type="radio" value="Inner Tube" >Inner Tube<br/>
<input style="display:inline;width:0px;;" name="eq_name" type="radio" value="Floating Cottage">Floating Cottage</br></br>
<input type="submit" value="Submit" onClick="return confirm('Submit form?')">
</form>
我对此代码块感到非常困惑。我一整天都在努力工作,并决定在这里发表我的问题以征求意见。
问题:我分配给变量的值没有插入到我的数据库中 dbname:islaDB(已经检查了5次) tablename:equiptable(这也是)
[小屋租赁用品的学校项目]
希望你们能帮助我解决这个问题:O提前谢谢