15 July 2012

Google API Login System Using PHP|Google Login

See The Live Demo::: Click Here

Download Script:::Click Here

The Step By Step Tutorial Is below::


Step1:We required a server.In this tutorial i work on 000Webhost. Which is free web hosting website.
Note:This Script is not run on local host.


Step2:After login you will see a screen as in my screenshot.Then Create a domain by clicking on create new domain.



Step3:After clicking create new you will see a screen as i shown in my screenshot.Then make a domain.i choose free domain.And named it as u want.And also choose a password.

Step4:After clicking on setup new account you will see a main page.Also remember you can create only one domain in 24 Hour.And After this step your domain is ready to use.

Step5:To make gmail login first step is create database.To Create a Database click on MySql.As Shown In Screenshot.



Step6:Create a Databse with name Users.Here The Login Data is stored.Also Gives Password.And then click on create databse.After clicking your database is created.


Step7:After clicking create databse you will see a screen shown below.Then click on ":go to control panel".


Step8:Then by clicking on control panel you will see main page then go to PHPMYADMIN as shown in screensot.


Step9:Then click  on php myadmin as shown in screenshot.


Step10:After clicking on phpmyadmin you will see a screen as shown below the click on sql and run the following query to create database tables.


CREATE TABLE users
(
id INT PRIMARY KEY AUTO_INCREMENT,
email VARCHAR(70), 
oauth_uid int(11),
oauth_provider VARCHAR(100),
username VARCHAR(100) 
);




Step11:To the tables click on the left side database name as in our screenshot shown.



Step12:After this step go to your server home page.And click on File Manager.



Step13:On clicking file manager you will see a Screen Like Below. Now click on the public html.


Step14:After clicking public html you will see a screen like below.Then click on the upload button.
NOTE:Dont click on java upload button.



Step15:In this step you have to upload the script.To download the script 
click here.Before uploading the file we have to make some changes.

The first step here is to change the dbconfig.php file.


define('DB_SERVER', 'dbserver');
define('DB_USERNAME', 'username');
define('DB_PASSWORD', 'password');
define('DB_DATABASE', 'database');

define('USERS_TABLE_NAME', 'users_table_name'); //Replace your users table name here
$connection = mysql_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD) ordie(mysql_error());
$database = mysql_select_db(DB_DATABASE) or die(mysql_error());
?>


In this step give your Db Server Name,db Username,db Password,Db database Name.



Step16:login-google.php. In root directory find out the below line at login-google.php code and replaceyourdomain.com with your own domain value. 

define('CALLBACK_URL', 'http://yourdomain.com/getGoogleData.php');


Step17:index.php
If you want to modify your web project existing login or index pages, just use following code. 

session_start();
if (isset($_SESSION['id'])) {
// Redirect to home page as we are already logged in
header("location: home.php");
}
if (array_key_exists("login", $_GET)) 
{
$oauth_provider = $_GET['oauth_provider'];
if ($oauth_provider == 'google')
{
header("Location: login-google.php");
}
}
?>


Step18: home.php
In home page you can display user details by accessing session variables.


Name: 
Email: 
Your are logged in with: 
Logout from


So in this tutorial we will cover how to make domain and how to login with php.











No comments:

Top 9 Simple Things Every Computer User Should Know How to Do

10.     We all know we should back up our computers, but it’s always one of those things that you’ll set up “one day”.  Setting up a ba...