I am tried to insert the values into my wampserver, I succeed to insert name column and email column but it is not possible to insert pass word field into the database please check what I done mistake here.
above image gives you a clear idea, how that pass word field looks, note that that password field i tried to save the data in VARCHAR() but not save the data please check my below php and html codes
init.php
for database connection am using this
<?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>";
?>
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);
?>
register_test.html
this one is used for to send the details to the database, am using this one like as input to send data
<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>
please check this code, and please tell where i done the mistake to got the pass word values into my database
If your other two are getting inserted, try this:
$querys ="INSERT INTO userinfo (name,email,password) VALUES ('$name','$email','$pass');
$result = $mysqli_query($con,$querys);