Home  >  Article  >  Backend Development  >  小弟初学PHP。问下表单的提交有关问题

小弟初学PHP。问下表单的提交有关问题

WBOY
WBOYOriginal
2016-06-13 10:11:16900browse

小弟初学PHP。。。。。问下表单的提交问题
$connec=mysql_connect("localhost","root","vertrigo") or die("不能连接数据库服务器: ".mysql_error()); 
mysql_select_db("data",$connec) or die ("不能选择数据库: ".mysql_error()); 
mysql_query("set names 'utf8'");
?>
if($_POST["id"] and $_POST["action"]=="del")
{
$sql="delete from class where id=$_POST[id]";
mysql_query($sql,$connec);
echo("");
}
?>



 
 
 
 
 
 
$sql="select * from class order by ID desc";
$conn=mysql_query($sql,$connec);
while($rs=mysql_fetch_array($conn)){ 
?>
 
 
 
 
 
 
  

}
?>
ID classtitle classurl 操作
删除


老是有错误。。。。

想请问下如何判断form提交的动作?

还有,这样做不安全。如何做能有安全性?谢谢。

------解决方案--------------------
$_POST[id] 改为 $_GET[id]
------解决方案--------------------
报什么错呢?

判断用户类型,是否登录,就是最简易的安全检查。
------解决方案--------------------
删除
表单提交里面最常见的是提交之类,像超连接是用GET提交的。
去掉,然后用$_GET接收。
------解决方案--------------------
要对参数进行基本判断,判断是否为数值,判断传过来是否为空。

一般没什么问题。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn