为什么添加表单提交的数据传不到数据库里面,点击添加会清空。注释掉后面的add情况判断连接数据库是可以连得上的,能试的都试过了就是不知道问题出在哪里。麻烦大神帮我看看哪里有问题吧,我停在这个问题好久了。谢谢谢谢谢谢,感激不尽
表单
<body>
<div>
<form action="addAction.php?action=add" method="get">
<fieldset>
.......
</fieldset>
</div>
<div> <tr>
<td><a href="../right.php">返回</td>
<td><input type="submit" name="submit" value="添加"></td>
<td><input type="reset" name="reset" value="重置"></td>
</tr>
</form>
</div>
action操作
<?php
include '../function/conn.php';
if ($db_select){
switch ($_GET['action']){
case 'add'://add
$Rnumber = $_POST['Rnumber'];
$Raddress = $_POST['Raddress'];
$Rtype = $_POST['Rtype'];
$Rstate = $_POST['Rstate'];
$Remark = $_POST['Remark'];
$sql = "insert into room (room_id, room_address, room_type, room_state, room_remark) values ('$Rnumber', '$Raddress','$Rtype','$Rstate','$Remark')";
$rw = mysql_query($sql);
echo mysql_error();
if ($rw > 0){
echo "<script>alert('添加成功');</script>";
}else{
echo "<script>alert('添加失败');</script>";
}
}
}
header('Location: roomadd.php');
break;
?>
未完待续。。。2019-01-29 11:04:32
$sql = "insert into room (room_id, room_address, room_type, room_state, room_remark) values ('$Rnumber', '$Raddress','$Rtype','$Rstate','$Remark')";
把这个sql语句打印出来,去mysql管理工具上看看能不能运行。
而且“<form action="addAction.php?action=add" method="get">”,
你表单用的get提交,接收数据又用的post
$Rnumber = $_POST['Rnumber'];
$Raddress = $_POST['Raddress'];
$Rtype = $_POST['Rtype'];
$Rstate = $_POST['Rstate'];
$Remark = $_POST['Remark'];