This question already has an answer here:
<?php
include 'config.php';
function getid()
{
$fname = @$_POST['fname'];
$lname = @$_POST['lname'];
$email = @$_POST['email'];
$password = @$_POST['password'];
if (@$_POST['login'])
{
$qry = "insert into register values (NULL, '$fname', '$lname',
'$email', '$password')";
mysqli_query($conn, $qry);
}
};
Calling of the function in another file where the html exists:
include 'Config\api.php';
getid($conn, $_POST);
getid();
Taking into consideration that the code is working outside of the function which means that the connection is working and there is no problem with the coding or variables. Thank you.
</div>