利用php可以读取数据库的内容,但是当提交表单到数据库,点击submit按钮的时候却出现
Access forbidden!
You don't have permission to access the requested object. It is either read-protected or not readable by the server. If you think this is a server error, please contact the webmaster. 以下是源码:
<html>
<body>
<?php
if ($submit) {  
  // 处理表格输入  $db = mysql_connect("localhost", "root");  mysql_select_db("mydb",$db);  $sql = "INSERT INTO employees (first,last,address,position)
  VALUES ('$first','$last','$address','$position')";  $result = mysql_query($sql);  echo "Thank you! Information entered.\n";} else{  
  // 显示表格内容  ?>  <form method="post" action="<?php echo $PATH_INFO?>">
  
  名:<input type="Text" name="first"><br>
  
  姓:<input type="Text" name="last"><br>
  
  住址:<input type="Text" name="address"><br>  职位:<input type="Text" name="position"><br>  <input type="Submit" name="submit" value="输入信息">  </form>  <?php} // end if,if结束
?></body></html>

解决方案 »

  1.   

    貌似初学php时见过这问题(iis??),服务器没有打开post/get权限
      

  2.   

    我比较喜欢用isset($_POST['name'])这样的形式来判断
      

  3.   

    if ($submit) {改成 :if (isset($_POST['submit']) && !empty($_POST['submit'])) {
      

  4.   

    if ($submit) {改成 :if (isset($_POST['submit']) &amp;&amp; !empty($_POST['submit'])) {仍出现access forbidden。能接收提交过来的值
      

  5.   

    你先把php的报错机制给打开把,如果有错误的话,最好开发的时候可以把错误级别调到最低,所有错误都进行提示!
      

  6.   

    错误提示是有读保护或没读取权限。加代码,判断是否成功连接mysql服务器,和是否成功打连接库。