doutuzhuohao6449 2017-04-13 22:22
浏览 20

数据没有被添加到phpmyadmin上的数据库中

I am using wamp server.I am trying to store the data which user fill in my form.But i don't know why its not getting added. These are my php files:(all files wrote in notepad++)

init.php:

<?php
$host = "localhost";
$db_user = "harsh";
$db_password = "password";
$db_name = "user_db";

 $con = mysqli_connect($host,$db_user,$db_password,$db_name);

?>

register1.php:

<?php
require "init.php";

$name = $_POST["name"];
$adharnumber = $_POST["adharnumber"];
$email = $_POST["email"];
$password = $_POST["password"];
$contact = $_POST["contact"];

$sql="select * from individualuser_info where email like '".$email."';";

$result = mysqli_query($con,$sql);
$response = array();

    if(mysqli_num_rows($result)>0)
{
    $code = "reg_failed";
    $message = "User already exist....";
    array_push($response,array("code"=>$code,"message"=>$message));
    echo json_encode($response);
}
 else
{


    $sql = "insert into individualuser_info (`".$name."','".$adharnumber."','".$email."','".$password."','".$contact."');";
    $result = mysqli_query($con,$sql);
    $code = "reg_success";
    $message = "thank you .now you can login....";
    array_push($response,array("code"=>$code,"message"=>$message));
    echo json_encode($response);
}
mysqli_close($con);

?>

My form register_test.html:

<html>

<body>
<form action ="register1.php", method="post">
<table>
<tr>
<td>Name : </td><td><input type="text" name="name"/></td>
</tr>

<tr>
<td>Adhar number : </td><td><input type="text" name="adharnumber"/></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>Contact:</td><td><input type="text" name="contact"/></td>
</tr>

<tr>
<td><input type = "submit" value="Register"/></td>
</tr>

</table>
</form>
</body>
</html>

After making this files after starting wampserver when i am typing localhost/register_test.html in chrome url. It displays the form but unexpectedly in the email field it shows loacalhost automatically and in password field displays some password. And after filling the details when i click on register it shows message [{"code":"reg_success","message":"thank you .now you can login...."}]. But in database user_db in my individiualuser_info table no records gets added. Please help me to solve this.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?