我试图将值插入到我的wampserver中,我成功插入了名称列和电子邮件列,但是无法将密码字段插入数据库中,请检查我在这里做错了什么。
上面的图片给你一个清晰的想法,如何通过字段的外观,请注意,我试图在VARCHAR()中保存数据的密码字段但不保存数据请检查我的下面的PHP和HTML代码
的的init.php
使用此
<?php
$user_name="root";
$pass="";
$host="localhost";
$db_name="userdb";
$con=mysqli_connect($host,$user_name,$pass,$db_name);
if(!$con)
{
echo "Connection Failed....".mysqli_connect_error();
}
else
echo "<h3>Connection Success.....</h3>";
?>
&#13;
register.php
<?php
$name=$_POST["name"];
$email=$_POST["email"];
$pass=$_POST["password"];
require "init.php";
$query="select * from userinfo where email like '".$email."';";
$result=mysqli_query($con,$query);
//ok
if(mysqli_num_rows($result)>0)
{
$response=array();
$code="reg_false";
$message="User already exist....";
array_push($response,array("code"=>$code,"message"=>$message));
echo json_encode(array("server_response"=>$response));
}
else
{
$querys ="insert into userinfo values ('".$name."','".$email."','".$pass."');";
$result=mysqli_query($con,$querys);
if(!$result)
{
$response=array();
$code="reg_false";
$message="Some server error occurred, Train again....";
array_push($response,array("code"=>$code,"message"=>$message));
echo json_encode(array("server_response"=>$response));
}else{
$response=array();
$code="reg_true";
$message="Registration Success....Thank you....";
array_push($response,array("code"=>$code,"message"=>$message));
echo json_encode(array("server_response"=>$response));
}
}
mysqli_close($con);
?>
&#13;
register_test.html
这个用于将详细信息发送到数据库,使用这个作为输入发送数据
<html>
<head> <title>Register Test....</title> </head>
<body>
<form method="post" action="register.php">
<table>
<tr>
<td>Name :</td><td><input type="text" name="name"/></td>
</tr>
<tr>
<td>Email :</td><td><input type="text" name="email"/></td>
</tr>
<tr>
<td>Password :</td><td><input type="password" name="password"/></td>
</tr>
<tr>
<td><input type="submit" value="Register"/></td>
</tr>
</table>
</form>
</body>
</html>
&#13;
请检查此代码,并告诉我在哪里弄错了将密码值输入我的数据库