So I have this scenario. I have an adroid app sending a post variable to a php file on a server. I have a php file on a server that accepts a post variable and executes a function based on the variable recieved.
I can echo these variables and i will recieve them on my device.
I can set the $action variable by myself and it will be processed by the switch as needed.
But I cannot send my own variable and process it as it should be able to.
Ive tried setting the permissions of the php file to 777 and that didnt work.
This is the code below. All the help would be appreciated. Thanks.
<?php
require_once('config.php');
require_once('functions.php');
$action = $_POST['action'];
if(isset($action) && !empty($action)){
$connection = connect(USERNAME, PASSWORD, DATABASE);
switch($action){
case "sign_up":
sign_up($connection);
break;
case "social_sign_up":
social_sign_up($connection);
break;
case "social_sign_in":
social_sign_in($connection);
break;
case "new_testimony":
new_testimony($connection);
break;
case "new_comment":
new_comment($connection);
break;
case "get_all_testimonies":
get_all_testimonies($connection);
break;
case "get_all_comments":
get_all_comments($connection);
break;
case "sign_in":
sign_in($connection);
break;
}
mysqli_close($con);
}
?>
EDIT I've isolated the problem to prepared statements that are executed inside the sign_in function. I've checked that the module exists and it does. This is the sign in function
//sign in
function sign_in($connection){
if(
isset($_POST['email']) && !empty($_POST['email']) &&
isset($_POST['password']) && !empty($_POST['password'])
){
$email = $_POST['email'];
$password = $_POST['password'];
$count = NULL;
$id = NULL;
$fname = NULL;
$lname = NULL;
$stmt = $connection->prepare("select count(*), id, fname, lname from user where email = ? and password = ?");
$stmt->bind_param("ss", $email, $password);
if($stmt->execute()){
$stmt->bind_result($count, $id, $fname, $lname);
$stmt->fetch();
if($count == 1)
echo json_encode(array($id, $fname, $lname));
else
echo "Ensure your e-mail and password are correct.";
}
$stmt->close();
} echo false;
}
I get a fileNotFoundError on my device when i try to echo past the "$stmt = $connection->prepare" point.