<?php
include('connection.php');
require_once 'yahoo/openid.php'; $yahooid = new LightOpenID("a2zebhelp.com"); $yahooid->identity = 'https://www.yahoo.com/accounts/o8/id'; $yahooid->required = array( 'namePerson/first', 'namePerson/last', 'contact/email',);
$yahooid->returnUrl = 'http://a2zwebhelp.com/login-yahoo.php'; ?>
Now Add the following code to "Login with Yahoo"
button.
<a href="<?php echo $yahooid->authUrl() ?>">Login with Yahoo</a>
if ($yahooid->mode == 'cancel') { echo "User has canceled authentication !"; } elseif($yahooid->validate()) { $data = $yahooid->getAttributes(); $email = $data['contact/email']; $firstname = $data['namePerson/first']; $lastname = $data['namePerson/last']; $Identity = explode("=",$yahooid->identity); $userid = $Identity[1]; $loginwith = 'Yahoo'; $sql = mysql_query("select userid from register where passcode='".$userid."'"); $numrow = mysql_num_rows($sql); if($numrow > 0){ header('Location:myaccount.php'); exit(); } }
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'); }
CREATE TABLE IF NOT EXISTS `register_yahoo` ( `id` int(11) NOT NULL AUTO_INCREMENT, `firstname` varchar(50) DEFAULT NULL, `lastname` varchar(50) DEFAULT NULL, `email` varchar(60) DEFAULT NULL, `gender` varchar(10) DEFAULT NULL, `passcode` varchar(100) DEFAULT NULL, `profilepic` varchar(250) DEFAULT NULL, `loginwith` varchar(10) DEFAULT NULL, `status` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;