I a trying to add column id which will be a primary key with auto increment properties. So i execute this SQL query:
ALTER TABLE  `user_info` ADD  `id` INT NULL AUTO_INCREMENT PRIMARY KEY FIRST ;
The column is created successfully and even creates id for the already existing data.
But i am unable to insert anything inside the table anymore.
<?php
require "init.php";
$name=$_POST["user"];
$user_email=$_POST["user_email"];
$user_pass=$_POST["user_pass"];
$sql_query="SELECT * FROM user_info WHERE user_email='$user_email'";
$check=mysqli_fetch_array(mysqli_query($con,$sql_query));
if(isset($check)){
 $response["success"]=false;
 $response["message"]="Email already exists";
 echo json_encode($response);
}else{
 $sql_query="insert into user_info values('$name','$user_email','$user_pass');";
if(mysqli_query($con,$sql_query)){
 //echo "<h3> Data Insert success</h3>";
    $response["success"]=true;
 $response["message"]="Registration successful";
 echo json_encode($response);
}
else{
  $response["success"]=false;
 $response["message"]="Registration unsuccessful";
 echo json_encode($response);
}
}
?>I googled around and found out that i could insert 0 or null in place of my id.
I purposefully read that :
In order to take advantage of the auto-incrementing capability of the column, do not supply a value for that column when inserting rows. The database will supply a value for you.
The code works well when i drop column id but when i add it, i get response as Registration unsuccessful within my json.
The workarounds from here or here did not seem to solve my problem.
What am i missing?
 
     
     
    