Login/ Register With Yahoo Open Id

social media

This article will guide you to crate login/ register with Yahoo.

The process and steps are same as login/ register through Gmail. You only need to change the path from https://www.yahoo.com/accounts/o8/id to https://me.yahoo.com.

Step1:

Include your database connection file and openid.php to you login page.

<?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 the user enters the correct info then Yahoo page will redirect back to or login page with required information's.

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 the user registered before then our system will redirect the user to my account page otherwise it will ask the user to register for the first time.

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');
}

The MySql table used in this project
CREATE TABLE IF NOT EXISTS `register` (
`userid` int(11) NOT NULL AUTO_INCREMENT,
`fastname` varchar(50) NOT NULL,
`lastname` varchar(50) NOT NULL,
`email` varchar(100) NOT NULL,
`password` varchar(100) NOT NULL,
`passcode` varchar(100) NOT NULL,
`loginwith` varchar(20) NOT NULL,
`status` varchar(10) NOT NULL,
PRIMARY KEY (`userid`),
UNIQUE KEY `userid` (`userid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
 

Other Login/ Registration Systems

Login/ Register With Facebook
Login/ Register With Twitter
Login/ Register With Linked In
Login/ Register With Gmail
Login/ Register With Hotmail
Login/ Register With Email

Download Code Files Total Downloads: 1933

Comments
26 December
2013
harsh
myaccount.php file is missing how to get this file.when I have download a file then we will not get myaccount.php file please send whole file in my email id-harshkumar283@gmail.com
comments powered by Disqus