I am having an error with slim PHP framework 3.
"The requested resource /try/foo@bar.com/secret was not found on this server."
I am new to slim PHP framework. When I enter email address " foo@bar " and password " secret " it yields a blank error (ie ""
). When I enter email address " baz " and password " secret2 " then it yields no error message.
I am basically making web service for Android, where the user will enter an email address and password and the required query will be returned in JSON format.
$app - > get('/try/{email}/{password}', function($request, $response, $args) {
include_once('db.php');
$email = $request - > getAttribute('email');
echo $email;
$password = $request - > getAttribute('password');
echo $password;
$sql = "select * from user where email='$email' and password='$password'";
echo $sql;
$result = mysqli_query($con, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
$data[] = mysqli_fetch_assoc($result);
header('Content-Type:application/json');
echo json_encode($data);
} else {
echo "0 results";
}
mysqli_close($con);
});
@
is not a valid character inside an url: (see https://stackoverflow.com/a/1856809/1172363 )
You must create your link with urlencoded email value...
$app->urlFor("your_route_name", array("email" => urlencode($mail), "password" => urlencode($password));
In your case it would be (for example):
Actually I solved this problem by encoding the parameter with Base64 logic.
btoa(criteria)
In the endpoint (mine is PHP) I did a base64decode operation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.