header location is not working, im stuck in the same page - mysqli

hey all i have this code, the query works totally fine but the header no please help , this is my code i appreciate it
<?php
if (isset($_POST['login'])){
$username=$_POST['username'];
$pass=$_POST['password'];
$hashedpass=md5($pass);
$query="SELECT username, password FROM users WHERE username='$username' AND password='$hashedpass'";
echo $query;
$run=mysqli_query($con, $query);
$rows=mysqli_num_rows($run);
if ($rows > 0){
$_SESSION['username'] = $username;
header('Location: index.php');
exit();
}
}
?>
Username
Password

Try writing complete uri and delete exit
header('Location: http://www.domain/index.php');

Related

Retrieve users/company information

On connecting to Quickbook within our app we are able to get access token and realmid but on trying to implement Get App Now we couldn't get any information after redirecting to our openid url. What I have tried so far is
define('OAUTH_CONSUMER_KEY', $consumerkey);
define('OAUTH_CONSUMER_SECRET', $consumersecret);
define('OAUTH_URL', 'https://oauth.intuit.com/');
define('APPCENTER_URL', 'https://appcenter.intuit.com/');
define('OAUTH_REQUEST_URL', OAUTH_URL . 'oauth/v1/get_request_token');
define('OAUTH_ACCESS_URL', OAUTH_URL . 'oauth/v1/get_access_token');
define('OAUTH_AUTHORISE_URL', APPCENTER_URL . 'Connect/Begin');
define('OAUTH_CURRENT_USER', APPCENTER_URL . 'api/v1/user/current');
try{
$oauth = new OAuth(OAUTH_CONSUMER_KEY,OAUTH_CONSUMER_SECRET,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_URI);
$oauth->enableDebug();
$request_token = $oauth->getRequestToken(OAUTH_CURRENT_USER,CALLBACK_URL);
echo '<pre>';
print_r($_POST);
print_r($_GET);
print_r($_REQUEST);
print_r($_SESSION);
echo $request_token;
print_r($request_token);
echo '</pre>';
} catch(OAuthException $e) {
pr($e);
}
I can't get any valuable information on the above code, I maybe doing it wrong and expecting that there would be realmid and access token once the authorization is done and quickbooks redirect to our openid url. Any information would be appreciated.
Please note I really don't have knowledge about this as this is my first time using quickbooks api and related technologies.
Updated
<?php
require 'openid.php';
try {
# Change 'localhost' to your domain name.
$openid = new LightOpenID($_SERVER["HTTP_HOST"]);
if(!$openid->mode) {
if(isset($_GET['login'])) {
$openid->identity = 'https://openid.intuit.com/OpenId/Provider';//'https://www.google.com/accounts/o8/id';
$openid->required = array(
'contact/email',
'namePerson/first',
'namePerson/last'
);
header('Location: ' . $openid->authUrl());
}
?>
<form action="?login" method="post">
<button>Login with Google</button>
</form>
<?php
} elseif($openid->mode == 'cancel') {
echo 'User has canceled authentication!';
} else {
echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.';
}
} catch(ErrorException $e) {
echo $e->getMessage();
}
When the form above gets submitted it results into No OpenID Server found at https://openid.intuit.com/OpenId/Provider

Facebook login with codeigniter working in localhost but not working on server(live),?

please help me, I am in little trouble. I am familiar with codeigniter.
but I struggling with Login in With Facebook button. I included all files like facebook.php and base_facebook. Its working in Localhost but not working on server. please help me to fix this issue. when I click login button it's responding blank. I given my controller coding below. Thanks in advance.
public function check_fb()
{
$this->load->model('users/users_model');
$appId = '************'; //Facebook App ID
$appSecret = '************'; // Facebook App Secret
$homeurl = 'Site URL'; //return to home
$fbPermissions = 'email'; //Required facebook permissions
parse_str($_SERVER['QUERY_STRING'],$_REQUEST);
$this->load->library('Facebook', array("appId"=>"******", "secret"=>"*******"));
$fbuser = $this->facebook->getUser();
// Here it self I did't get any response.
if(!$fbuser){
$fbuser = null;
$loginUrl = $this->facebook->getLoginUrl(array('redirect_uri'=>$homeurl,'scope'=>$fbPermissions));
//echo $loginUrl; exit;
redirect($loginUrl);
}
else
{
$user_profile = $this->facebook->api('/me?fields=id,first_name,last_name,email,gender,locale,picture');
$user = new Users();
//echo "<pre>"; print_r($user_profile); exit;
if(!empty($user_profile)){
if(!empty($user_profile['id']))
{
$check=$this->users_model->check_login_facebook_id($user_profile['id']);
if($check)
{
echo 'already Exist';
}
else
{
$result = $this->users_model->update_login_facebook_id($user_profile['id']);
redirect($this->config->item('base_url').'users/dashboard');
}
}
}
}
}
Above code is working pretty cool..! I made mistake in library folder. I renamed base_facebook.php as Base_facebook.php, its case sensitive. if anyone face like this problem, just check twice your library files name. Facebook.php ,base_facebook.php, Fb_ca_chain_bundle security certificate.

Facebook login loads landing page inside popup window

After signing up to my site as a new member, redirect page is loaded inside the FB login popup window. And I can not figure it out.
if (!session_id()) session_start();
$_SESSION['userid'] = $user_id;
$_SESSION['FirstName'] = $fname;
$_SESSION['loginFb'] = $logoutUrl;
header("Location: sign-up/welcome");
echo "<script>
window.close();
window.opener.location.reload();
</script>";
exit();
How should the code has to be corrected in order to get the redirection page in the main browser?
header("Location: sign-up/welcome");
In general PHP executed before HTML, CSS and JS does that's why, remove it and it should work
if (!session_id()) session_start();
$_SESSION['userid'] = $user_id;
$_SESSION['FirstName'] = $fname;
$_SESSION['loginFb'] = $logoutUrl;
echo "<script>
window.close();
window.opener.location.reload();
</script>";
exit();

weird php error - cannot explain just in title

discovered this forum a few days ago and still not into it enough to contribute - will happen soon i hope :)
right now i am experiencing something weird i hope someone can help me with.
In the following php code:
when i run it and enter a valid username and password, it will always send me to failed.php although it should have returned a result.
When i add a random "echo" before the if clause, it goes into the correct branch, but of course can't do the header("Location..) any more.
Does anyone have an idea what i am missing here or why this is happening?
Could it be some PHP setting i am not aware of?
thanks in advance
Seb
(NOTE i know php4 is not up to date, sql injections etc. - i just want to know and maybe understand why this is happening ;) )
<?php
include("config.php");
$query = 'select * from users where username = "' .
$_POST['username'] . '" and password = "' .
md5($_POST['password']) . '"';
$select_user = mysql_query($query);
//echo "something";
if ($select_user && ($row = mysql_fetch_row($select_user)))
{
$user_id = $row[0];
session_start();
session_register('authorized');
$_SESSION['authorized'] = true;
$_SESSION['uid'] = $user_id;
//echo "anothersomething";
header("Location: portal.php");
exit;
}
else
{
$_SESSION['authorized'] = false;
$_SESSION['uid'] = 0;
header("Location: failed.php");
exit;
}
#MYSQL_CLOSE($db);
?>

Facebook infinite redirect loop during authentication

I am getting an infinite loop in the URL redirect after a user either logs in or is already logged in. The page redirects to the login page if the user is not logged in as expected , but goes in the loop as soon as he enters the credentials.
Following is the code:
<?php
include_once ('facebook.php');
$api_key = 'xxxxxxxxxxxx';
$secret = 'xxxxxxxxxxxx';
global $facebook;
$facebook = new Facebook($api_key, $secret);
$facebook->require_frame();
$uid = $facebook->require_login($required_permissions = 'email,status_update,offline_access');
$facebook->api_client->users_hasAppPermission("offline_access",$uid);
#echo $uid;
# $facebook->api_client->users_setStatus("hello",$uid);
# echo "<p>Your status has been updated</p>";
?>
Interestingly this code was working before, but suddenly started giving me an infinite loop problem. There have been couple of discussion on facebook forum about this but no indication that is a bug or what is the workaround .
Any help would be highly appreciateed.
Thanks
I added the code to direct to login only if the user is not logged in else do not do that. This worked for me! .. Hope it helps.
$is_tab = isset($_POST['fb_sig_in_profile_tab']);
if( !$is_tab ){
$uid = $facebook->require_login($required_permissions = 'email,status_update ,offline_access');
}
else{
$uid = $facebook->get_profile_user();
}