<body>
<form action="herozhuce.php" method="post"> <div>账号<input type="text" name="account"/></div> <div>密码<input type="text" name="password"/></div> <div>名字<input type="text" name="name"/></div> <div>位置<input type="text" name="location"/></div> <div>住址<input type="text" name="address"/></div> <div><input type="submit" value="添加" /></div></form></body><?php
$account = $_POST["account"];$password = $_POST["password"];$name = $_POST["name"];$location = $_POST["location"];$address = $_POST["address"];$db = new MySQLi("localhost","root","","wuma");
$sql = "insert into hero values('{$account}','{$password}','{$name}','{$location}','{$address}')";if($db->query($sql)){ echo "添加成功!";}else{ echo "添加失败!";}