$email = trim($_POST['email']);
$pass = md5(trim($_POST['password']));
$user = R::findOne("user"," email = ? AND password = ? ", array($email,$pass));
if($user != NULL) {
// good login
header('Location: http://www.google.com/');
} else {
// bad login
}
Now the framework we are provided already in redbean to create the login script is in this file which runs when we submit any form on website -
require_once('xyz.class.php');
if (isset($_REQUEST['apiName']) && $_REQUEST['apiName'] != null) {
$apiName = $_REQUEST['apiName'];
switch ($apiName) {
case 'requestSignUp':
echo UberHealth::requestSignUp($_REQUEST['email']);
break;
case 'contact':
echo UberHealth::contact($_REQUEST['email'], $_REQUEST['msg'], $_REQUEST['name'], $_REQUEST['subject']);
break;
...
}
}
and xyz.class.php has redbean functions for logging in / sign up etc. Now when i login through this script this gives me an error on console like -
XMLHttpRequest cannot load http://www.google.com/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.
I have tried
return header('Location: http://www.google.com/');
return json_encode(header('Location: http://www.google.com/'));
instead of just header('Location: ...'));
But gave the same error.
