Login with Twitter


Twitter Login API allows the user to sign into the website using their Twitter account without sign up on that website. Here we can give an option to the user to register/ login to our system with their Twitter Account. The process is like this: If the user click on "Login with Twitter" button then it will ask Twitter user name and password. If the user is using the system first time then it will fill up the registration form and display first name, last name, email and Gender fields. There will be no password field as the user is register / connect through Gmail. Once the user click on submit, our system will save the data in the server with the reference number sent by Twitter. Next time when the user come and click on "Login with Twitter" our system will check the reference number in our database, if it matches then it will sent the user directly to My Account page.
You can download the attached file and get the basic html form and other required files used in this project.

You need to generate Twitter Consumer Key and Consumer Secret.

Click here to generate required Key for Twitter.
Save the keys in config.php file.

config.php

<?php
define("Consumer_Key", "Your Key Here");
define("Consumer_Secret", "Your Key Here");
?>

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.

/*Check if the user connected before */
$sql = db_query("select * from register_twitter where passcode='".$passcode."'");
$numrow = mysqli_num_rows($sql);
if($numrow > 0){
	$_SESSION['email'] 		= $email;
	$_SESSION['passcode'] 	= $passcode;
	
	header('Location:myaccount.php');
	exit();
}
$btnstatus  = "";

The MySql table used in this project
CREATE TABLE IF NOT EXISTS `register_twitter` (
  `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 Linked In
Login/ Register With Yahoo!
Login/ Register With Gmail
Login/ Register With Hotmail
Login/ Register With Email

Top