Join Over 10,000 Blogger Tricks !

Tuesday, March 31, 2015

How to Login with Google Account OpenID

This post explains you about how to Login with Google account OpenID authentication in PHP.

OpenID is an open standard that describes how users can be authenticated in a manner that is decentralized, allowing users to consolidate their digital identities and eliminating the requirement for services to provide their particular ad hoc systems.

This is only because the OpenId supplier is trusted to have verified all details of the user.
Login with Google Account OpenID
Accepting OpenId login on a site has advantages like :
  1. Quick form-less enrollment for users. Makes user experience. Thus increased enrollment/conversion rates.
  2. Lesser validation of user information like e-mail verification etc.
  3. Faster logins. Users are mainly logged in for their preferred openid suppliers, and so the login happens simply by making a click!
Over here we shall see just how to execute the "Login with Google Account OpenID" attribute to some website using Google's openid supplier.

Login with Google Account OpenID

Following below steps to How to Login with Google Account OpenID:

1. Database

Create database user table columns id, email, oauth_uid, oauth_provider and username.
CREATE TABLE users(id INT PRIMARY KEY AUTO_INCREMENT,email VARCHAR(70), oauth_uid int(11),oauth_provider VARCHAR(100),username VARCHAR(100) );

2. Database Configuration

Create database and add details of your database in dbconfig.php file as like below:
<?php
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());?>

3. Google Login Config File

Edit login-google.php file that you can find in root directory and replace yourdomain.com to your website URL.
define('CALLBACK_URL', 'http://yourdomain.com/getGoogleData.php');

4. Index Page Configuration

If you add login on your exiting page than add following code on your index page:
<?phpsession_start();if (isset($_SESSION['id'])) {// Redirect to home page as we are already logged inheader("location: home.php");}if (array_key_exists("login", $_GET)) {$oauth_provider = $_GET['oauth_provider'];if ($oauth_provider == 'google'){header("Location: login-google.php");}}?>//HTML Code<a href="?login&oauth_provider=google">Google Login</a>

5. Home.php Configuration

Name: <?php $_SESSIONS['username'] >Email: <?php $_SESSIONS['email'] >Your are logged in with: <?php $_SESSIONS['oauth_provider'] ><a href="logout.php?logout">Logout</a> from  <?php $_SESSIONS['oauth_provider'] >

Download Script Now

Google Account OpenID

Monday, March 30, 2015

How to Login with Facebook and Twitter

Facebook and Twitter have become large in the social network world and both networks offering oAuth support. We developed a system for login with Facebook and Twitter. Today internet users not interested to filling the large enrollment forms. This script gives you the capacity to avoid enrollment forms, It Is is easy and really useful to incorporate.

Twitter and Facebook have grown to be big in both networks offering oAuth and the social network world support. If all they must do is login using their present Facebook account visitors will likely be a lot more inclined to become members and participate in your web site.
Login with Facebook and Twitter
It uses OAuth and workflow and the authority URL differs somewhat as described below, although the flow is quite similar.

Login with Facebook and Twitter

Please follow below steps to learn and add Login with Facebook and Twitter on your websites easily:

1. Database

Create new database with users table columns id, email, oauth_uid, oauth_provider and username.
CREATE TABLE users
(id INT PRIMARY KEY AUTO_INCREMENT,email VARCHAR(70), oauth_uid VARCHAR(200),oauth_provider VARCHAR(200),username VARCHAR(100), twitter_oauth_token VARCHAR(200), twitter_oauth_token_secret VARCHAR(200) );

2. Twitter Setup

Create Twitter application from twitter website and replace Twitter Key & Twitter Secret Key in twconfig.php file as shown below code.
<?phpdefine('YOUR_CONSUMER_KEY', 'Twitter Key');define('YOUR_CONSUMER_SECRET', 'Twitter Secret Key');?>

3. Facebook Setup

Create Facebook application from facebook website and replace Facebook APP ID & Facebook Secret ID in fbconfig.php file as shown below code.
<?phpdefine('APP_ID', 'Facebook APP ID');define('APP_SECRET', 'Facebook Secret ID');?>

4. Databas Configuration

Add your database details in dbconfig.php file as shown below code:
<?phpdefine('DB_SERVER', 'localhost');define('DB_USERNAME', 'username');define('DB_PASSWORD', 'password');define('DB_DATABASE', 'database');$db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);?>

5. Twitter Login Config

In your root directory you can see login-twitter.php. Edit this file and replace yourwebsite.com to your main domain name.
$request_token = $twitteroauth->getRequestToken('http://yourwebsite.com/getTwitterData.php');

6. Index Page Config

If you want to add your own index page than you can change your index page with adding below codes in your index page.
<?phpsession_start();if (isset($_SESSION['id'])) {// Redirection to login page twitter or facebookheader("location: home.php");}if (array_key_exists("login", $_GET)) {$oauth_provider = $_GET['oauth_provider'];if ($oauth_provider == 'twitter'){header("Location: login-twitter.php");}else if ($oauth_provider == 'facebook') {header("Location: login-facebook.php");}}?>//HTML Code<a href="?login&oauth_provider=twitter">Twitter_Login</a><a href="?login&oauth_provider=facebook">Facebook_Login</a>
Click below button for  download full code script and extract to edit code to edit on your website for login with facebook and twitter.
facebook and twitter login

Sunday, March 29, 2015

Add Your Site/Blog URL in Google Search Database

Since it's definitely the most effective way of bringing free, targeted visitors to your own web site it's critically crucial that you get your web site listed on the top search engines like Google like Google. This site gets most of its own traffic in the search engines who send people to our web pages.
Understanding this can permit you to enhance your articles and general web site by executing some search engine Optimization (SEO) techniques.

Add Site in Google Search Database

How Can Search Engines Rank Your Website?

Before we look at the way you begin submitting your site to the top search engines like Google, it is significant that you simply learn the basics of the things it is that they look for when rating your site/site. The higher you rank on Bing Google & Yahoo, the more traffic you'll receive. But being recorded does not automatically mean traffic will be attracted by you, you need to optimize your website to 'see' you correctly.

Every internet search engine functions differently from one another. Typically, these take into consideration your; Page Title, Meta Description, Key Words Amount Of Inbound Links, in your articles, Bounce Rate, etc. Do not worry, it is really a lot less complex than it seems.

Each search engine differs, as I say

Read our post on 'On-Page SEO Techniques' for more information about exactly what the search engines are seeking on your pages.

Do I Have To Submit My Website?

All search engines use software called 'Spiders' to crawl the internet. These search for brand spanking new content, which is later added to their own databases/index in the web. The results come from this database, therefore it is essential for the website to be recorded with this database when individuals run searches on internet search engines like Google.

Technically you do not need to submit your website to any search engines, by crawling the web, as finally they'll locate your website. Nevertheless, this may take time, time where possible traffic is loosing by not being recorded. You speed up the entire procedure by being added to the search engines database by submitting your website yourself.

Submit Your Website URL in Google Search Database

Follow below steps to add your website or blog in Google search database to get rank in Google.

Step 1

Login into Google Webmaster Tools Website as shown in below picture.

Add Blog in Google Search Database

Step 2

After add your website you need to Verify Your Site URL as shown in below picture.
Google Search Database

Step 3

Copy meta tag verification code and paste it on index page of the website as shown in below picture.

Add Your Site URL in Google Search Database

Step 4

After saving your home page click on verify button in webmaster tool as shown in below picture.
Add Your Blog URL in Google Search Database

Step 5

Now add sitemap in Google webmaster tool in XML format and you can generate XML sitemap from http://www.xml-sitemaps.com.

Add Your Site/Blog URL in Google Search Database

Your site will be added in Google search engine database within 2-3 weeks.

Saturday, March 28, 2015

Email Verification Script in PHP

I received lots tutorial requests from my readers in that almost all of these requested to me, the best way to execute PHP Email Verification Script. That is really essential tutorial described the best way to generate appropriate and database activation code. Executed with mysqli_() fuctions, because mysql_() functions are depreciated.

Email Verification Script in PHP

PHP Email Verification Script

Follow below steps to create Email Verification Script in PHP. You can create your own PHP Email Verification scripts as your requirement. You can add all data in your php file folder or download already created file at the end of the post:

Database

Create database which contains four columns uid, email, password, activation and status.
CREATE TABLE IF NOT EXISTS `users` (
`uidint(11) NOT NULL AUTO_INCREMENT,
`emailvarchar(300) NOT NULL UNIQUE,
`passwordvarchar(300) NOT NULL,
`activationvarchar(300) NOT NULL UNIQUE,
`statusenum('0','1') NOT NULL DEFAULT '0',
PRIMARY KEY (`uid`)
)

HTML Code

<form action="" method="post">
<label>Email</label>
<input type="text" name="email" class="input" autocomplete="off"/>
<label>Password </label>
<input type="password" name="password" class="input" autocomplete="off"/><br/>
<input type="submit" class="button" value="Registration" />
<span class='msg'><?php echo $msg; ?></span>
</form>

db.php

Create database contain file with your database username and password.
<?php
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'username');
define('DB_PASSWORD', 'password');
define('DB_DATABASE', 'database');
$connection = @mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);
$base_url='http://www.youwebsite.com/email_activation/';
?>

index.php

<?php
include 'db.php';
$msg='';
if(!empty($_POST['email']) && isset($_POST['email']) && !empty($_POST['password']) &&  isset($_POST['password']) )
{
// username and password sent from form
$email=mysqli_real_escape_string($connection,$_POST['email']);
$password=mysqli_real_escape_string($connection,$_POST['password']);
// regular expression for email check
$regex = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/';

if(preg_match($regex, $email))

$password=md5($password); // encrypted password
$activation=md5($email.time()); // encrypted email+timestamp
$count=mysqli_query($connection,"SELECT uid FROM users WHERE email='$email'");
// email check
if(mysqli_num_rows($count) < 1)
{
mysqli_query($connection,"INSERT INTO users(email,password,activation) VALUES('$email','$password','$activation')");
// sending email
include 'smtp/Send_Mail.php';
$to=$email;
$subject="Email verification";
$body='Hi, <br/> <br/> We need to make sure you are human. Please verify your email and get started using your Website account. <br/> <br/> <a href="'.$base_url.'activation/'.$activation.'">'.$base_url.'activation/'.$activation.'</a>';

Send_Mail($to,$subject,$body);
$msg= "Registration successful, please activate email.";
}
else
{
$msg= 'The email is already taken, please try new.';
}

}
else
{
$msg = 'The email you have entered is invalid, please try again.'; 
}

}
// HTML Part
?>

Send_Mail.php

<?php
function Send_Mail($to,$subject,$body)
{
require 'class.phpmailer.php';
$from       = "[email protected]";
$mail       = new PHPMailer();
$mail->IsSMTP(true);            // use SMTP
$mail->IsHTML(true);
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Host       = "tls://smtp.yourwebsite.com"; // SMTP host
$mail->Port       =  465;                    // set the SMTP port
$mail->Username   = "SMTP_Username";  // SMTP  username
$mail->Password   = "SMTP_Password";  // SMTP password
$mail->SetFrom($from, 'From Name');
$mail->AddReplyTo($from,'From Name');
$mail->Subject    = $subject;
$mail->MsgHTML($body);
$address = $to;
$mail->AddAddress($address, $to);
$mail->Send(); 
}
?>

activation.php

<?phpinclude 'db.php';$msg='';if(!empty($_GET['code']) && isset($_GET['code'])){$code=mysqli_real_escape_string($connection,$_GET['code']);$c=mysqli_query($connection,"SELECT uid FROM users WHERE activation='$code'");
if(mysqli_num_rows($c) > 0){$count=mysqli_query($connection,"SELECT uid FROM users WHERE activation='$code' and status='0'");
if(mysqli_num_rows($count) == 1){mysqli_query($connection,"UPDATE users SET status='1' WHERE activation='$code'");$msg="Your account is activated"; }else{$msg ="Your account is already active, no need to activate again";}
}else{$msg ="Wrong activation code.";}
}?>//HTML Part<?php echo $msg; ?>

htaccess

RewriteEngine On
RewriteRule ^activation/([a-zA-Z0-9_-]+)$ activation.php?code=$1
RewriteRule ^activation/([a-zA-Z0-9_-]+)/$ activation.php?code=$1

CSS code

body
{
font-family: "Helvetica",Arial,sans-serif;
font-weight: 500;
color:#333;
}
label
{
width:100px;
display:block;
font-weight:bold;
color:#666666;
}
#main
{
margin:0 auto;
width:800px;
}
.input
{
padding:10px;
font-size:14px;
border:1px solid #999999;
width:200px;
margin-bottom:10px;
}
.button {
padding:10px;
background-color: #5fcf80 !important;
border-color: #3ac162 !important;
}
.msg
{
font-size:11px;
color:#666;
padding:10px;
}
 Email Verification Script

Don't Forget To Join US Our Community
x