Gelukkig nieuwjaar!!!
Ik heb een probleem bij het schrijven van een systeem waarmee je kan registreren en inloggen met Google.
Ik heb van de site http://www.a2zwebhelp.com/login-with-google een code gevonden die ik nu gebruik alleen Google zecht: "Fout:invalid_request. Error in parsing the OpenID auth request."
Wat is er fout?
hier onder ziet je de code:
login-google.php:
<?php
include('connection.php');
if($_POST['register']){
$fname = mysql_real_escape_string($_POST['fname']);
$lname = mysql_real_escape_string($_POST['lname']);
$email = mysql_real_escape_string($_POST['email']);
$passcode = mysql_real_escape_string($_POST['passcode']);
$loginwith = mysql_real_escape_string($_POST['loginwith']);
$status = 'active';
$mysql = mysql_query("insert into register set fastname = '".$fname."',
lastname = '".$lname."',
email = '".$email."',
passcode = '".$passcode."',
loginwith = '".$loginwith."',
status = '".$status."'");
header('Location:myaccount.php');
}
/* Login With Google */
require_once 'google/openid.php';
$googleid = new LightOpenID("localhost");
$googleid->identity = 'https://www.google.com/accounts/o8/id';
$googleid->required = array(
'namePerson/first',
'namePerson/last',
'contact/email',
);
$googleid->returnUrl = 'localhost/login-google.php';
if ($googleid->mode == 'cancel') {
echo "User has canceled authentication !";
} elseif($googleid->validate()) {
$data = $googleid->getAttributes();
$email = $data['contact/email'];
$firstname = $data['namePerson/first'];
$lastname = $data['namePerson/last'];
$Identity = explode("=",$googleid->identity);
$userid = $Identity[1];
$loginwith = 'Google';
$sql = mysql_query("select userid from register where passcode='".$userid."'");
$numrow = mysql_num_rows($sql);
if($numrow > 0){
header('Location:myaccount.php');
exit();
}
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Login With Google</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="content">
<div class="login_left">
<span class="linkedin"><a href="<?php echo $googleid->authUrl() ?>"><img border="0" src="images/login_with_google.png" width="273" height="60"></a> </span><br/>
</div>
<form method="POST" action="?register=true">
<div class="login_right">
<label>First Name</label> <span class="txtbox"> <input type="text" name="fname" class="input_box" placeholder="Enter First Name" autocomplete="off" required value="<?php print $firstname; ?>"> </span>
<label>Last Name</label> <span class="txtbox"> <input type="text" name="lname" class="input_box" placeholder="Enter Last Name" autocomplete="off" required value="<?php print $lastname; ?>"> </span>
<label>Email</label> <span class="txtbox"> <input type="email" name="email" class="input_box" placeholder="Enter Email Address" autocomplete="off" value="<?php print $email; ?>"></span>
<?php if($loginwith ==""){ ?>
<label>Password</label> <span class="txtbox"> <input type="password" name="password" class="input_box" placeholder="Enter Password" required></span>
<?php } ?>
<input type="hidden" name="passcode" value="<?php print $userid; ?>"></span>
<input type="hidden" name="loginwith" value="<?php print $loginwith?>"></span>
<div class="submit_box"><input type="submit" value="Submit" name="register"> </div>
<div>
</form>
</div>
</body>
</html>
[size=xsmall]Toevoeging op 01/01/2014 14:36:17:[/size]
Weet iemand iets?