Monday, 26 May 2014

custom search engine


This topic i explain about how to make search engine in your site. this is simple concept your posted value directly search on google search engine. that value posted on form action page follow the below code and live demo

HTML

<form method="get" action="http://google.com/search">

<p>
<input name="q" placeholder="Just type your text here press enter ex : Mostlikers"  type="text" class="search" />
</p>
<p align="center">
<input type="submit" name="submit" id="click" class="but" value="Mostliker search"  />
 <input type="submit" name="submit" class="but" value="I m Feeling lucky" /> </p> 
<p class="lang">mostlikers.co.in offered in: 
<a href="#">Hindi</a>&nbsp;<a href="#"> Bengali </a>&nbsp;
<a href="#">Telugu </a>&nbsp;<a href="#">Marathi </a>&nbsp;
<a href="#">Tamil </a>&nbsp;<a href="#">Gujarati</a><a href="#">
 Kannada</a>&nbsp;<a href="#"> Malayalam</a></p>
</form>

form action posted on direct to google page just type your text its posted on google search engine

CSS

.login form { width:600px; height:0 auto;  margin:0 auto; }
.search { border: 1px solid #ccc;width:572px;min-height: 30px;
padding: 4px 20px 4px 8px;font-size: 18px;-moz-transition: all .2s linear; 
-webkit-transition: all .2s linear;transition: all .2s linear;}
.search:hover { width: 572px;border-color:#999999;}       
.search:focus { width: 572px;border-color:#03F;outline: none;}
.but{ padding: 6px 10px;color: #222;border-radius:3px solid #00F;
border:1px solid #CCC;background: #f4f4f4;margin-bottom:4%;font-weight:bold;cursor:pointer;
font-size:75%;font-family: arial,sans-serif;-moz-border-radius: 3px ;-webkit-border-radius: 3px;
border-radius: 3px ;  }
.but:hover { padding: 6px 10px;color: #222;background: #f4f4f4;margin-bottom:4%;
cursor:pointer;font-size:75%;border-color:#f7f7f7;font-family: arial,sans-serif;
-moz-border-radius: 3px ;-webkit-border-radius: 3px; border-radius: 3px ;  }
.but:before { content: '��'; } 
.lang a{ font-weight:100px;text-decoration:none;}


Wednesday, 21 May 2014

facebook style login system

Today i posted on facebook style login form using PHP and CSS 3. facebook login form username accept on 3 types email id, Phone number, facebook email id this are 3 ways to login to facebook if user can enter wrong password  search to the databasse to fetch the matching  username to display image in login form. similar like i make this coding. 


                 Download

Flow chart Design



Flow chart description :

user enter username and password its check to the login table. after user confirmation allow to welcome page else page go login.php page if username or phone number correct password only error page going on login error.php.

Database 

CREATE TABLE `login`
(
  `m_id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(150) NOT NULL,
  `password` varchar(150) NOT NULL,
  `phone` varchar(150) NOT NULL,
  `image` varchar(150) NOT NULL,
)

Functionality files
1.index.php
2.login.php
3.Welcome.php
4.logout.php

index.php

<?php 
session_start();
ob_start();
if(isset($_SESSION['m_id'])!="")
{
    header('Location:welcome.php');
}
if(isset($_SESSION['users'])!="")
{
    header('Location:login.php');
}
else
{   
}

$db = new mysqli('localhost', 'root', '', 'facebook');// change the database connections
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>mostlikers</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="topBar">
<div>
<div class="clearfix logout_menubar">
<a class="toptitle" href="http://karthickinfotech.blogspot.in/" title="Mostliker">
<img src="logos.png">
</a>
<div class="menu_login_container rfloat _ohf">
<form id="login_form" action="login.php" method="post">
<table cellspacing="0">
<tbody>
<tr><td class="maintext">
<label for="email">Email or Phone</label></td>
<td><label for="pass">Password</label></td>
</tr>
<tr>
<td><input type="text" class="inputtext" name="email" id="email" value="" tabindex="1"></td>
<td><input type="password" class="inputtext" name="password" id="pass" tabindex="2"></td>
<td>
<input value="Log In" class="subbutton" name="login" type="submit"></td></tr>
<tr>
<td>
<div>
<input type="checkbox" name="keepme" value="1" checked="1">
<label for="persist_box">Keep me logged in</label>
</div>
</td>
<td>
<a href="#">Forgot your password?</a></td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
</div>
</div>
<div class="mostlikers-bottom">
<h3><a href="karthickinfotech.blogspot.in/p/chat.html">
Click more mostlikers Demos</a></h3></div>
</body>
</html>


login.php

<?php 
session_start();
$db = new mysqli('localhost', 'root', '', 'facebook');// change the database connections
?>
<?php
if(isset($_POST['login']))
{
    $email=$_POST['email'];
    $pwd=$_POST['password'];
    if($email!="" and $pwd!="")
    {
   $checkdb2=$db->query("select * from login where username='$email' and password='$pwd' ");
   $check=mysqli_num_rows($checkdb2);
   if(empty($check))
   {
       $checkdb2=$db->query("select * from login where phone='$email' and password='$pwd' ");
        $check=mysqli_num_rows($checkdb2);
        if(empty($check))
   {
        $checkdb2=$db->query("select * from login where phone='$email' and password!='$pwd' ");
        $check2=mysqli_num_rows($checkdb2);
        
        if(empty($check2))
        {
            $checkdb2=$db->query("select * from login where username='$email'");
        $check2=mysqli_num_rows($checkdb2);
        }
   }
    }
    }
    else {
         echo "<script>window.location='login.php?login_failed=1'</script>";
          }
          
          if($check)
{
    
    while($image=mysqli_fetch_object($checkdb2))
         {
             $_SESSION['users']= $image->username;
             $_SESSION['images']= $image->image;
             $_SESSION['phone']= $image->phone;
             $_SESSION['m_id']= $image->m_id;
         }
         
          echo "<script>window.location='welcome.php'</script>";
}
 else  {
         }
        if($check2)
{
    
    while($image=mysqli_fetch_object($checkdb2))
         {
             $_SESSION['users']= $image->username;
             $_SESSION['images']= $image->image;
             $_SESSION['phone']= $image->phone;
             
         }
         
         echo "<script>window.location='login.php?login_failed=1'</script>";
}
 else  {
         }
        
       
   }
   

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>mostlikers</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="topBar">
<div>
<div class="clearfix logout_menubar">
<a class="toptitle" href="http://karthickinfotech.blogspot.in/" title="Mostliker">
<img src="logos.png">
</a>
</div>
</div>
</div>

<div class="logbox">
<div class="logbox2">
<h2>Mostlikers Login</h2>
<hr>
<div id="Logbox3">
<?php
if(isset($_GET['login_failed'])=='1')
{
?>
<div class="Error_box" style="color:#000; text-align:center; background:#FFEBE8; border:#F00 solid 1px;">
<span><p><h4>Invalid user login</h4></p>
    <p>Check your username and password</p>
    </span>
</div>
<?php
}
else
{
}
?>
<div id="logtable">
<form method="post">
<table width="449" align="center" border="0">
<?php
if(isset($_SESSION['users'])!="")
{
?>
  <tr>
    <td class="logtable_con" width="94" height="100">Login as :</td>
    <td width="165">
    <div style="width:165px; margin-top:20px;">
    <div style="float:left; width:60px; height:55px;" class="image_error">
    <img src="uploade/<?php echo $_SESSION['images'] ?>" width="50" height="50" /><p>
    <a href="logout.php">Not <?php echo $_SESSION['users'];  ?> </a></p>
    </div>
    <div style="float:left; width:60px; height:55px;" class="user_error">
    <div style="font-size:13px; font-weight:bold;"><?php echo $_SESSION['users'];  ?></div>
    <div><?php echo $_SESSION['phone'];  ?></div>
    </p>
    
    </div>
    </div>
    
    <input type="hidden" class="inputtext2" name="email" id="email" value="<?php echo $_SESSION['users']; ?>"  size="30"></td>
  </tr>
  <?php
}
else
{
?>
<tr>
    <td width="94" height="49">Login us</td>
    <td width="165"><input type="text" class="inputtext2" name="email" id="email" value=""  size="30"></td>
  </tr>
 <?php } ?>
    <td  height="38">Password</td>
    <td><input type="password" class="inputtext2" name="password" id="email" size="30" value="" tabindex="1"></td>
  </tr>
 
  <tr>
    <td height="22">&nbsp;</td>
    <td><input id="persist_box" type="checkbox" value="1"  name="persistent" class="uiInputLabelInput uiInputLabelCheckbox"><label>
    Keep me Logeed in</label>
    </td>
  </tr>
  <tr>
    <td height="53">&nbsp;</td>
    <td><input value="Log In" name="login" tabindex="4" type="submit" class="subbutton"></td>
  </tr>
  <tr>
    <td height="21">&nbsp;</td>
    <td><a href="#">For get your password ?</a></td>
  </tr>
</table>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!--<div class="mostlikers-top">
<a href="http://karthickinfotech.blogspot.in/">
<img  name="mostlikers" style="border:none; margin-left:60px;"   height="80" src="logos.png" title="mostlikers" alt="mostlikers" /></a>
<div class="logbox">
<div class="userbox">
<p><label>Email or Phone</label></p>
<p><input type="text" name="email" size="15" /></p>
<p>Keep me logged in</p>
</div>
<div class="passbox">
<p><label>Password</label></p>
<p><input type="text" name="email" size="15" /></p>
<p>Keep me logged in</p>
</div>
</div>
</div>


<div class="login">
<div class="comment_box">

<div>
<hr />
</div>
</div>
<div class="clear"></div>
    <div class="comment_box">
   
    </div>

<!--client side add information-->
<div class="addnew">

</div>
</div>
</div> <div class="mostlikers-bottom">
<h3><a href="karthickinfotech.blogspot.in/p/chat.html">Click more mostlikers Demos</a></h3></div>-->
</body>
</html>

Welcome.php

<?php
session_start();
ob_start();
$db = new mysqli('localhost', 'root', '', 'facebook');// change the database connections
?>
<html>
<head>
<title>mostlikers</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div  style="border:#CCC solid 1px; width:892px; margin:auto; margin-top:100px;">
<table width="891" height="288" border="0">
  <tr>
    <td colspan="2"><div align="center"><h2>Thanks to Login  Click here <a href="logout.php">logout Page</a></h2></div><hr/></td>
 
  </tr>
  <tr>
    <td width="389" height="185"><div style=" width:181px; height:181px; margin-left:10px; border:#CCC solid 2px;">
    <img src="uploade/<?php echo $_SESSION['images'] ?>" width="180" height="180" /></div></td>
    <td width="492">
   <h3> <p>Username : <?php echo $_SESSION['users'] ?><br/><br>

    Role     : Web Developer </br><br>

    Link : <a href="http://karthickinfotech.blogspot.in/">Mostlikers.com</a></p></h3>
    
    </td>
  </tr>
  <tr>
    <td colspan="2"><hr/><div align="center"><h3><a href="http://karthickinfotech.blogspot.in/">Click Here More Live Demos code developer Karthick</a></h3></div></td>
  </tr>
</table>
</div>
</body>
</html>

Logout

<?php
session_start();
session_destroy();
header('Location:index.php');
?>

style.css

body {
background: #fff;
color: #333;
line-height: 1.28;
margin: 0;
padding: 0;
text-align: left;
direction: ltr;
unicode-bidi: embed;
font-family: 'lucida grande',tahoma,verdana,arial,sans-serif;
font-size: 11px;
overflow-y: scroll;
}


#topBar {
background-color:#f2f2f2;
border-bottom: 1px solid #CCC;
min-width: 981px;
position: relative;
z-index: 300;
}

.clearfix {
zoom: 1;
}
.loggedout_menubar {
margin: 0 auto;
width: 980px;
padding-top:13px;
}

.clearfix:after {
clear: both;
content: ".";
display: block;
font-size: 0;
height: 0;
line-height: 0;
visibility: hidden;
}

.toptitle {
float: left;
}


.clearfix {
zoom: 1;
}
a {
color: #3b5998;
cursor: pointer;
text-decoration: none;
}

form {
margin: 0;
padding: 0;
}
user agent stylesheetform {
display: block;
margin-top: 0em;
}

body, button, input, label, select, td, textarea {
font-family: 'lucida grande',tahoma,verdana,arial,sans-serif;
font-size: 11px;
}
input[type="hidden"], input[type="file"] {
-webkit-appearance: initial;
padding: initial;
background-color: initial;
border: initial;
}
input[type="password"] {
-webkit-appearance: textfield;
padding: 1px;
background-color: white;
border: 2px inset;
border-image-source: initial;
border-image-slice: initial;
border-image-width: initial;
border-image-outset: initial;
border-image-repeat: initial;
-webkit-rtl-ordering: logical;
-webkit-user-select: text;
cursor: auto;
}
input, textarea, keygen, select, button, isindex {
margin: 0em;
font: -webkit-small-control;
color: initial;
letter-spacing: normal;
word-spacing: normal;
text-transform: none;
text-indent: 0px;
text-shadow: none;
display: inline-block;
text-align: start;
}

table[Attributes Style] {
border-spacing: 0px;
}
table {
border-collapse: separate;
border-spacing: 2px;
border-color: gray;
}
._ohf {
float: right;
}
.maintext {
padding-bottom: 4px;
color:#333;
}
.menu_login_container table tr td {
padding: 0 0 0 14px;
}
td, td.label {
text-align: left;
}

th {
display: table-cell;
vertical-align: inherit;
}
.subbutton {
background-color: #5b74a8;
border-color: #29447e #29447e #1a356e;
color:#CCC;
}

.inputtext, .menu_login_container .inputpassword {
border-color: #1d2a5b;
margin: 0;
width: 142px;
}
.inputtext2, {
border-color: #6699FF;
margin: 0;
width: 400px;
}
.inputtext, .inputpassword {
padding-bottom: 4px;
}
textarea, .inputtext, .inputpassword {
border: 1px solid #bdc7d8;
margin: 0;
padding: 3px;
-webkit-appearance: none;
-webkit-border-radius: 0;
}
input, textarea, keygen, select, button, isindex {
margin: 0em;
font: -webkit-small-control;
color: initial;
letter-spacing: normal;
word-spacing: normal;
text-transform: none;
text-indent: 0px;
text-shadow: none;
display: inline-block;
text-align: start;
}
input[type="submit"], input[type="reset"] {
-webkit-appearance: push-button;
-webkit-user-select: none;
white-space: pre;
}
.logbox
{
    width:625px;
    height:auto;
    border: solid #CCC 1px;
    border-radius:5px;
    margin:0 auto;
    margin-top:80px;
}
.logbox2
{
    width:575px;
    margin:0 auto;
}
.Logbox3
{
    clear: left;ss
margin: auto;
padding: 20px 0 0 10px;
text-align: left;
width: 380px;
}
.logtable_con
{
font-weight:bold;
color: #666;
text-outline:#9C9;
}
.logtable
{
    margin:auto;
}
.mostlikers-bottom
{
    height:40px;
    font-size:18px;
    background:#f2f2f2;
    text-align:center;
}

Wednesday, 14 May 2014


PHP Email and mobile number validation script


This post concept based on Email and mobile verification using in php script. Previously We using form validation on Jquery and Javascript so now check  the form validation in php. follow the below code let know as validation script.


View code                Download

Database

CREATE TABLE `page`
(
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) NOT NULL,
  `email` varchar(50) NOT NULL,
  `number` varchar(50) NOT NULL,
)

PHP

Email verification function based to check on regular expression its check user email. similar on mobile number validation.

<?php
if(isset($_POST['submit']))
{   
$name=mysql_real_escape_string($_POST['name']);
$email=mysql_real_escape_string($_POST['email']);
$phone=mysql_real_escape_string($_POST['phone']);
$emailval = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/';
$mob="/^[789][0-9]{9}$/";
if(!preg_match($emailval, $email))
{ 
    $msg="check your email";
        
}
else
{   
if(!preg_match($mob, $phone))
{ 
    $msg="check your Mobile number ";
        
}   
else
{       
        if(empty($name))
    {
            $msg="Check your name so Plese Enter Again";
        }
        
        else{
            
            $ins=mysql_query("insert into page(name,email,phone) values('$name','$email','$phone')");
            if($ins)
            {
                $msg="upload succefully";
            }
            
        }
     }
  }
     echo "<span style='font-size:24px; color:Red; font-weight:600;'>$msg</span>";
  }
   ?>


HTML

<form name="form" method="post">
<label>Name</label>
<input type="text" name="name" /><br />
<label>Email &nbsp;</label>
<input type="text" name="email" /><br />
<label>Phone</label>
<input type="text" name="phone" /><br />
<input type="submit" name="submit" value="submit" />
</form>

change password in php mysql code

change password in php mysql code

This concept based on Client side user change the old password  to new password. just simple way to change password in database using update query to validate the old password and change the new password. post the form value to store php variable and fetch the old password use if and else statement check the validate on old password if password match query will update the new password in database.

Database

create below fields in database table insert some sample value.

CREATE TABLE `users` (
`username` VARCHAR( 25 ) NOT NULL , 
`email` VARCHAR( 25 ) NOT NULL , 
`password` VARCHAR( 25 ) NOT NULL
) 
INSERT INTO users VALUES ('user', 'you@example.com', 'abc123');

PHP


fetch the email address in database Post old password value to store $passwordvalue=$_POST['cur_pwd']; using this if else statement password is correct  $login1="password changed"echo the form else display  $login1="password not match plz try again";  


 <?php 
       $hostname = "localhost"; // usually is localhost, but if not sure, check with your hosting company, if you are with webune leave as localhost 
$db_user = "root"; // change to your database password 
$db_password = ""; // change to your database password 
$database = "user"; // provide your database name 
//$db_table = "table"; // Your Table Name where you want to Store Your Image. 
# STOP HERE 
#################################################################### 
# THIS CODE IS USED TO CONNECT TO THE MYSQL DATABASE 
$db = mysql_connect($hostname, $db_user, $db_password); 
mysql_select_db($database,$db);
      if(isset($_POST['submit']))
      {
  function check_input($value)
{
// Stripslashes
if (get_magic_quotes_gpc())
  {
  $value = stripslashes($value);
  }
// Quote if not a number
if (!is_numeric($value))
  {
  $value = "" . mysql_real_escape_string($value) . "";
  }
return $value;
}
      $passwordvalue=$_POST['cur_pwd'];
      $password=$_POST['password'];
      $confirm_pwd=$_POST['confirm_pwd']; 
  $cur_pass=md5($passwordvalue); 
  $new_pass=md5($password); 
  $conf_pass=md5( $confirm_pwd);
  $username=$_SESSION['userName'];
      $select=mysql_query("select * from ABC where userName='$username'"); 
      $fetch=mysql_fetch_array($select);
      $data_pwd=$fetch['repassWord'];
      $email=$fetch['user_email'];

      if($new_pass==$conf_pass && $data_pwd==$cur_pass)
        {
      $insert=mysql_query("UPDATE ABC SET passWord='$conf_pass',repassWord='$conf_pass' WHERE  userName='$username'"); 
       $login1="password changed";
        }
      else
        {
      $login1="password not match plz try again";
        }
      }
      ?>

HTML


Enter the form value post on database
<form method="post" name="change">
<table border="0" cellpadding="0.1" style="margin-left:100px;">
  <tr>
    <td ><h2 class="style8">Change Password</h2></td>
    <td></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><?php echo $login1 ; ?></td>
  </tr>
  <tr>
    <td class="style10">old password<span class="style11">*</span>:</td>
    <td><input type="password" name="cur_pwd"  id="cur_pwd"  class="ser" /></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td class="style10">New password<span class="style11">*</span>:</td>
    <td><input type="password" name="password"  id="password" class="ser" /></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td class="style10">Confirm password<span class="style11">*</span>:</td>
    <td><input type="password" name="confirm_pwd" id="confirm_pwd" class="ser" /></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td align="center"><input name="submit" id="submit" type="submit" value="Save"  /></td>
    
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</form>