Facebook Chat Box

This post is about creating facebook chat box.Facebook Chat box  can be easily developed using css and some javascript lines.Below is code of Facebook Chat Box.

Menu Bar with Hover property

Navigation is very important for website.Navigation can be obtained through Menu bars.This post about the usage of Hover Property which is used to make menu more affective and also used for focus of users.Let see below image of Menu bar.


In this menu bar, when user hover mouse(moves mouse over menu tab) on menu tab background color  will be changed .This can be obtained through Hover property of CSS.

JQuery AJAX


AJAX program can be developed through jquery library. JQuery facilitates less code to implement AJAX.Following is simple code to  understand AJAX with JQuery.

Introduction to AJAX and check user availability using AJAX

AJAX stands asynchronous Javascript and XML. AJAX is techniques to load server content without loading page.There is alot of uses in web applications.AJAX is used to upload part of webpage without loading web page.Here we will see use of AJAX through "check user availability" program.

Famous application of AJAX is google Suggest.

Three Column Div based layout

Website is mostly designed in two column layout and three column layout.Three column layout is mostly used for website.First column is mostly used for navigation links ,Second column is used for content and third column is used for widgets or ads or banner.Following is Three Column layout.

Operand,Operators and Expression in PHP

Operator is a mathematical symbol which used to tell compiler to do mathematical operations and logical operations. Operators operates on variables and constants. These variables or constants are called operands. Operators and Operator form an expression.

   

Following are type of operators in PHP.

Increment & Decrement operators:-

 These operators are used for increasing and decreasing values of variable.These operators need only one operand so they operators are also called Unary operators.

Some examples of unary operators.
 
a++,++a,--a,a--


<?php
   $a = 10;
   echo $a++;
   echo "<br/>";
   echo ++$a;
   echo "<br/>";   
   echo --$a;
   echo "<br/>";
   echo $a--;
?>


Arithmetic Operator:- 

These operators are used for addition, substration , multiplication and divisions operations.These operators use two operands there fore These operators are also called binary operators.

Some examples of Binary Operators.
 
 +,-,*,/,%

<?php
   $a = 10;
   $b = 3;
   $c = $a + $b;
   echo $c;
   echo "<br/>";
   $c = $a - $b;
   echo $c;
   echo "<br/>";
   $c = $a * $b;
   echo $c;
   echo "<br/>";
   $c = $a / $b;
   echo $c;
   $c = $a % $b;
   echo $c;

?>



Assignment Operators:-

 These operatos are used for assign values to variables.

' =  ' is an example of assignment operator.

<?php
 
 $a = 20;  // Assignment Operator assign 20 to variable a
 echo $a ;

?>




Arthmetic Assignment Operators:-

 These operators are used for both arthmetic and assignment operation.
Below are examples of Arthmatic Assignment operators.
 +=,-=,*=,/=

<?php

   $a = 10;
   $b = 3;
   $b +=$a;
   echo $b;
     echo "<br/>";
   $b -=$a;
   echo $b;
   echo "<br/>";
   $b *=$a;
   echo $b;
   echo "<br/>";
   $b /=$a;
   echo $b;
   echo "<br/>";
?>



Comparison operators:-

 These operators are used for comparing variable values.
= =,<,>,!=  are examples of comparison operators.



<?php

$a = 20;

$b =20;

if($a == $b){

   echo "Equal";

}
$a = 20;
$b = 2;
echo "<br/>";

if($a != $b){

   echo "Not Equal";

}
echo "<br/>";

if($a > $b){

   echo "a greater than b";
}
echo "<br/>";
$a = 2;
$b = 20;
if($a < $b){

   echo "a less than b";

}

echo "<br/>";

if($a != $b){

   echo "a not equal to b";
}

?>






Logical Operators:-

These operators are used for logical operations like true or false.

&& , || , ! are logical operators.


<?php
$a = 20;
$b =20;
$c = 20;
if($a == $b && $a == $c){
   echo "true";
}
echo "<br/>";
if($a == $b || $a == $c){

   echo "true";

}
echo "<br/>";
$a =2;
$b = 3;
if($a != $b){

   echo "true";

}
?>


Login Form and Authentication in PHP


This post is about the Simple login form and Authentication in PHP.This Authentication is very basically used for an little application.More about Secure and Advanced Authentication will be discussed in later posts.


This is Simple login form you can used in any application . This consists of user name and password field and submit button.

Below is html code of Login Form




index.php
------------

<html>
  <head>
       <title>Login</title>
   </head>
   <body>
   <fieldset style="margin-right:600px;">
   <legend>Login</legend>
   <form action="auth.php" name="login" method="post">
       <table>
        <?php
            if(isset($_GET['msg'])){
        ?>
        <tr>
            <td><?php echo $_GET['msg'];?>
            </td>
        </tr>
           
        <?php       
           
            }
        ?>
        <tr>
            <td>User Name</td>
            <td><input type="text" name="user_name"/></td>
        </tr>
        <tr>
            <td>Password</td>
            <td><input type="password" name="password"/></td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td><input type="submit" name="submit" value="submit"/></td>
        </tr>
   </form>
   </fieldset>
  </body>
  </html>

After putting login details this form will submit for authentication.Following is Authentication Code.

auth.php
-----------
 
<?php
 $username = $_POST['user_name'];
 $pass = $_POST['password'];
 if($username == "john" AND $pass == "abc"){
     header("location:welcome.php");

 }
 else{
     header("location:index.php?msg=Invalid user name or password");
 }
?> 


If user is authenticated successfully then it will direct to Welcome page otherwise it will redirect to index page with error message.

Welcome.php
--------------

<html>
  <head>
       <title>Login</title>
   </head>
   <body>
      <h1>Welcome !</h1>
  </body>
  </html>



 Thanks For Reading..........