Hi, I'm new to this php, please help me please, these are the errors that are thrown
Notice: Undefined index: name in C: \ xampp \ htdocs \ Register.php on line 4
Notice: Undefined index: course in C: \ xampp \ htdocs \ Register.php on line 5
Notice: Undefined index: surname in C: \ xampp \ htdocs \ Register.php on line 6
Notice: Undefined index: user_name in C: \ xampp \ htdocs \ Register.php on line 7
Notice: Undefined index: password in C: \ xampp \ htdocs \ Register.php on line 8
Warning: mysqli_stmt_bind_param (): Number of elements in type definition string does not match number of bind variables in C: \ xampp \ htdocs \ Register.php on line 10 {"success": true}
and this is my code:
{<?php
$con = mysqli_connect("localhost", "root", "", "usuarios");
$name = $_POST["name"];
$course = $_POST["course"];
$surname = $_POST["surname"];
$user_name = $_POST["user_name"];
$password = $_POST["password"];
$statement = mysqli_prepare($con, "INSERT INTO usuarios(name,course,surname,user_name,password) VALUES (?, ?, ?, ?, ?)");
mysqli_stmt_bind_param($statement, "ssis", $name, $user_name, $course, $surname, $password);
mysqli_stmt_execute($statement);
$response = array();
$response["success"] = true;
echo json_encode($response);
?>}
this is from the other file
Notice: Undefined index: user_name in C: \ xampp \ htdocs \ Login.php on line 4
Notice: Undefined index: password in C: \ xampp \ htdocs \ Login.php on line 5
Warning: mysqli_stmt_bind_param () expects parameter 1 to be mysqli_stmt, boolean given in C: \ xampp \ htdocs \ Login.php on line 8
Warning: mysqli_stmt_execute () expects parameter 1 to be mysqli_stmt, boolean given in C: \ xampp \ htdocs \ Login.php on line 9
Warning: mysqli_stmt_store_result () expects parameter 1 to be mysqli_stmt, boolean given in C: \ xampp \ htdocs \ Login.php on line 11
Warning: mysqli_stmt_bind_result () expects parameter 1 to be mysqli_stmt, boolean given in C: \ xampp \ htdocs \ Login.php on line 12
Warning: mysqli_stmt_fetch () expects parameter 1 to be mysqli_stmt, boolean given in C: \ xampp \ htdocs \ Login.php on line 17 {"success": false}
code:
{<?php
$con = mysqli_connect("localhost", "root", "", "usuarios");
$user_name = $_POST["user_name"];
$password = $_POST["password"];
$statement = mysqli_prepare($con, "SELECT * FROM user WHERE user_name = ? AND password = ?");
mysqli_stmt_bind_param($statement, "ss", $user_name, $password);
mysqli_stmt_execute($statement);
mysqli_stmt_store_result($statement);
mysqli_stmt_bind_result($statement, $userID, $name, $course, $user_name,$surname, $password);
$response = array();
$response["success"] = false;
while(mysqli_stmt_fetch($statement)){
$response["success"] = true;
$response["name"] = $name;
$response["course"] = $course;
$response["surname"] = $surname;
$response["user_name"] = $user_name;
$response["password"] = $password;
}
echo json_encode($response);
?>}
thanks