Login with Yahoo!


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

The process and steps are same as login/ register through Gmail.
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_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 ;
 

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



Demo   Pay $1.49 & Download File



Top