html - Gets the correct response but MySQL database does not update, with PHP -


i trying create simple registration form. have file connecting database

conn.php

<?php  $db_name = "bp_reader";  $mysql_username = "root";  $mysql_password = "";  $server_name = "localhost";  $conn = mysqli_connect ($server_name, $mysql_username, $mysql_password, $db_name);  /*the connection here fine*/ if($conn){ echo "connected"; }else{ echo "not connected"; }  ?> 

the registration php

<?php require "conn.php";  $name = $_post["name"]; $email = $_post["email"]; $age = $_post["age"]; $height = $_post["height"]; $weight = $_post["weight"]; $password = $_post["password"];  //check if user exists $sql = "select * user_profile user_email '".$email."';";  $result = mysqli_query($conn, $sql);  $response = array();  if(mysqli_num_rows($result) > 0){      $code = "registration failed";     $message = "user exists";       array_push($response, array("code"=>$code, "message"=>$message));      echo json_encode($response);  }else {     $sql = "insert user_profile values ('".$name."', '".$email."', '".$age."', '".$height."', '".$weight."', '".$password."');";      $result = mysqli_query($conn, $sql);      $code = "registration success";     $message = "thank registration... can login now..";      //jason data     array_push($response, array("code"=>$code, "message"=>$message));      echo json_encode($response); }  mysqli_close($conn); ?> 

and have simple html registration form

<html>  <body> <form action="register.php" method="post">     <table>         <tr>             <td>name:</td>             <td>                 <input type="text" name="name" /> </td>         </tr>         <tr>             <td>email:</td>             <td>                 <input type="email" name="email" /> </td>         </tr>         <tr>             <td>dob:</td>             <td>                 <input type="date" name="age" /> </td>         </tr>         <tr>             <td>height:</td>             <td>                 <input type="number" name="height" /> </td>         </tr>         <tr>             <td>weight:</td>             <td>                 <input type="number" name="weight" /> </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> 

the problem when fill form , submit, correct response registration successful when check database on phpmyadmin, database remain unchanged. not able figure out problem is.

if have id field identifier , autoincrement, should set its:

   $sql = "insert user_profile values ('', '".$name."', '".$email."', '".$age."', '".$height."', '".$weight."', '".$password."');"; 

Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -