drbmhd9583 2012-05-10 09:33
浏览 39
已采纳

PHP从Textbox向WAMP服务器发送信息导致错误

I don't get any errors, but when i click submit nothing happens.

Just wanted to try this simple code before putting in values in the textboxes, but even this does not add a record. I don't understand what is wrong.

<form method="post" action="">   
User Name: <input type="text" name="UN"><br>    
Password: <input type="text" name="PW"><br>   
 <input type="Submit" name = "submit" value="Add User">  
</form>

<?php 
$mysql = new mysqli('localhost', 'root', 'password', 'db')
 or die ('you\'re dead');

if (mysqli_connect_errno()) {    
  exit('Connect failed: '. mysqli_connect_error());    
}

if(isset($_POST['Submit'])) {    
   $quer = "INSERT INTO 'unpw'('id' , 'username', 'password') VALUES 
    (? , 'hello' , 'world')";

    $mysql->query($quer);

    if ($mysql->query($query) === TRUE) {  
      echo 'users entry saved successfully';    
    } else {    
     echo 'Error: '. $mysql->error;    
    }

    $mysql->close();

}    
?>

展开全部

  • 写回答

1条回答 默认 最新

  • dongxibo2095 2012-05-20 13:54
    关注

    Variables are case sensitive in PHP.

    You are checking for $_POST['Submit'], when it should be $_POST['submit']; as you have written in <input type="Submit" name ="submit" value="Add User"> - the submit code is never triggered.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部