Greetings!
I am getting this error and won't be able to resolve it.
**Notice: Undefined index: usname in C:\xampp\htdocs\Mytestsite\api\student_insert.php on line 2
Notice: Undefined index: pass in C:\xampp\htdocs\Mytestsite\api\student_insert.php on line 3
Notice: Undefined index: nm in C:\xampp\htdocs\Mytestsite\api\student_insert.php on line 4
Notice: Undefined index: rl in C:\xampp\htdocs\Mytestsite\api\student_insert.php on line 5
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, bool given in C:\xampp\htdocs\Mytestsite\api\student_insert.php on line 12
{"status":0,"data":"No Record Found"}**
Any help will be appreciated.
this is what my code looks like.
<?php
$userName=$_POST['username'];
$Password=$_POST['pass'];
$Name=$_POST['name'];
$Rol=$_POST['rol'];
$conn = mysqli_connect("localhost","root","","bd_mytesttable");
if ($conn) {
$obj=array();
$query= "INSERT INTO tbl_user(username,password,name,rol)VALUES('$userName','$Password','$Name','$Rol')";
$query_result=mysqli_query($conn,$query);
if (mysqli_num_rows($query_result)>0) {
$row = mysqli_fetch_assoc($query_result);
array_push($obj, array(
"id" =>$row['id'] ,
"username" =>$row['username'] ,
"password" =>$row['password'] ,
"name" =>$row['name'] ,
"rol" =>$row['rol'], ));
echo json_encode(array("status"=>1, "data"=>$obj));
}
else
{
echo json_encode(array("status"=>0, "data"=>"No Record Found"));
}
// else
// {
// echo "No connection";
}
?>
[Mod: Added [code]...[/code] tags]