Translate

Thursday 10 October 2013

PHP Server Variable using foreach Condition

index.php:

<?PHP

foreach($_SERVER as $key_name => $key_value) {

print $key_name . " = " . $key_value . "<br>";

}

?>
 
In this coding foreach Condition is used to which Browser the user is to working and 
which remote address &IP address all information is to be display. 

Wednesday 9 October 2013

Server Variables in PHP to find the Referrer,Browser&IP Address

Coding:

<?php
$referrer = $_SERVER['HTTP_REFERER'];
$browser = $_SERVER['HTTP_USER_AGENT'];
$ipAddress = $_SERVER['REMOTE_ADDR'];

print "Referrer = " . $referrer . "<BR>";
print "Browser = " . $browser . "<BR>";
print "IP Adress = " . $ipAddress;
?>
 
In the above coding is usefull to find out which browser the user is to be working 
on&which ip address&which referrer (i.ein which domin&folder the user is working).
Try this Script. 

Tuesday 8 October 2013

Trim Function Coding

Coding:

<?PHP

//$space = "creatersite";
$space = trim(" hello ");//trim() is to remove space
$letCount = strlen($space);
print $letCount;

?>
 
In this Coding why we have to use trim function to remove the space between the letters
and characters 
$space = trim(" hello ");
We didn't use the trim function we can see that there is extra space before and after 
the text take and count the length.$space = "creatersite";
Try this script 

Sunday 6 October 2013

To View PDF File in Lightbox Using CSS&Javascript

Screenshot:
                                       
Explanitation:
                                         In this concept Like an Light box only.In Light box concept if u click an option that image will be viewed zoom that image.Likewise in the same concept i'll give coding for to view/display the PDF File in an lightbox concept.

index.php:

<html>
<link href="style2.css" rel="stylesheet"/>
<link href="style1.css" rel="stylesheet"/>
<script type="text/javascript" src="j.js"></script>
<script type="text/javascript" src="j1.js"></script>
</head>
<body>
<a style="width:144px;" href="parameters1.pdf" id="fb_26" class="demo" data-fb-options="className:floatbox;caption:href;">
<img id="fb_27" class="plain" src="pdf_108.jpg" alt="" height="108" width="144"></a>
</body>
</html>

Download CSS:style1.css,style2.css
Download js :j.js,j1.js

Thursday 3 October 2013

Onload pointer in field using Javascript

Screenshot:

                                                
index.php:

<body id="bdy" onload="document.contactform.name.focus();"></body>
contactform-->formname,
name-->fieldname


onload="document.contactform.name.focus();" we have to put this coding in inside the <body>tag.
contactform-->formname
name       -->fieldname      

Innerhtml Validation for a Form

Screenshot:
                       
index.php:

<form name="form1" method="post" onsubmit="return validation();">
<table width="30%" border="0" cellspacing="0" cellpadding="5" id="tbl">
  <tr>
    <td width="226" scope="col"><label for="first3">Firstname</label></td>
    <td width="248" scope="col"><input type="text" name="first" id="first3" /></td>
   <td width="30%" id="fname"></td>
  </tr>
  <tr>
    <td width="226" scope="col"><label for="last"> Lastname</label></td>
    <td width="248" scope="col">  <input type="text" name="last" id="last" /></td>
    <td width="30%" id="lname"></td>
  </tr>
  <tr>
    <td align="center" colspan="2"><input type="submit" name="submit" id="submit" value="Submit" /> </td>
    <td>&nbsp;</td>
  </tr>
</table>
</form>

validation.js:


function validation()
{

var nae=document.form1.first.value;
    if(nae=="" || nae=="null") 
    {
        document.getElementById('fname').innerHTML="Enter Firstname";
        document.getElementById('lname').innerHTML="";
        
        document.form1.first.focus();
        return false;
    }
    
    var nme=document.form1.last.value;
    if(nme=="" || nme=="null") 
    { 
        document.getElementById('fname').innerHTML="";
        document.getElementById('lname').innerHTML="Enter Lastname";
        
        document.form1.last.focus();
        return false;
    }
}

Monday 30 September 2013

By using JQuery to Post the response to Server

Screenshot:
                                        
index:
<div id="whole">      
    <div>First Name: <input type="text" id="first" value="creatersite"></div> <br />  
    <div>Last Name: <input type="text" id="last" value="Web Developer"></div> <br />  
    <div align="center"><input type="button" value="submit" onClick="doAjaxPost()"></div>  
      </div>
Script:
<script type="text/javascript" src="jquery-1.4.2.js"></script>  
<script>  
    function doAjaxPost() {  
     // get the form values  
     var field_a = $('#first').val();  
     var field_b = $('#last').val();  
      
     $.ajax({  
       type: "POST",  
       url: "serverscript.php",  
       data: "firstname="+field_a+"&lastname="+field_b,  
       success: function(resp){  
         // we have the response  
         alert("Server said:\n '" + resp + "'");  
       },  
       error: function(e){  
         alert('Error: ' + e);  
       }  
     });  
    }  
    </script> 

Saturday 28 September 2013

Tab Concept using Ajax

Screenshot:
                             

index.php:

<body>
<ul id="countrytabs" class="shadetabs">
<li><a href="home1.htm" rel="countrycontainer" class="selected">Tab 1</a></li>
<li><a href="home2.htm" rel="countrycontainer" id="favorite">Tab 2</a></li>
<li><a href="home3.htm" rel="countrycontainer">Tab 3</a></li>
<li><a href="home4.htm" rel="countrycontainer">Tab 4</a></li>
</ul>

<div id="countrydivcontainer" style="border:1px solid gray; width:450px; margin-bottom: 1em; padding: 10px; background-color:#000; color:#FFF;">
</div>
<script type="text/javascript">

var countries=new ddajaxtabs("countrytabs", "countrydivcontainer")
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init()

</script>
</body>
Downloads:script.js,style.css

Tuesday 24 September 2013

Characters change in upper&lower Case using PHP

Screenshot:
             


 Display:
                
 
index.php:

<body>
<form id="form1" name="form1" method="post" action="">
  <table width="200" border="1" cellspacing="0" cellpadding="5" id="tbl">
    <tr>
      <th>Characters Change in PHP</th>
    </tr>
    <tr>
      <td><label for="name">Name</label>
      <input type="text" name="name" id="name" /></td>
    </tr>
  
    <tr>
      <td align="center"><input type="submit" name="submit" id="submit" 
      value="Submit" /></td>
    </tr>
  </table>
</form>
</body>

Coding:

<?PHP
if (isset($_POST['submit'])) 
{

$full_name = $_POST['name'];
$full_name = ucwords( $full_name );
$change_to_lowercase = "CHANGE THIS";
$change_to_lowercase = strtolower($full_name);

$change_to_uppercase = "change this";
$change_to_uppercase = strtoupper($full_name);
}
?>
Apply After Closed html tag
<?php
echo"$full_name ";

echo"$full_sentence";

echo"$change_to_lowercase";

echo"$change_to_uppercase";

?>

Monday 23 September 2013

Multiplication Tables in PHP Coding

ScreenShot:
          

Display:

index.php:

<body>
<form id="form1" name="form1" method="post" action="">
  <table width="400" border="1" cellspacing="0" cellpadding="5" id="tbl">
    <tr>
      <td width="144"><label for="start">Multiply From</label></td>
      <td width="330"><input type="text" name="start" id="start" /></td>
    </tr>
    <tr>
      <td><label for="end">Multiplt To</label></td>
      <td><input type="text" name="end" id="end" /></td>
    </tr>
    <tr>
      <td><label for="mult">Multiply By</label></td>
      <td><input type="text" name="mult" id="mult" /></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" name="submit" id="submit" value="Submit" /></td>
    </tr>
  </table>
</form>
</body>

PHP Coding:

<?PHP

$times = 2;

if (isset($_POST['submit'])) {

$start = $_POST['start'];
$end = $_POST['end'];
$times = $_POST['mult'];

for($start; $start <= $end; $start++) {

$answer = $start * $times;
print $start . " multiplied by " . $times . " = " . $answer . "<BR>";

}

}

?>

Sunday 22 September 2013

Change Password using Javascript

index.php:


<form name="form1"  method="post" onsubmit="return checkPasswordMatch();" >
<ul>
<li>
    <label for="usermail">Email</label>
    <input name="usermail" size="40"  required="" type="email" />
</li>

<li>
    <label for="password">Password</label>
  <input type="password"  id="txtNewPassword" size="40" required="required" autocomplete="off" name="password"></li>
                  
<li>
     <label for="password">Re-Password</label>
      <input type="password"  autocomplete="off" size="40" id="txtConfirmPassword" required="required"  name="password2">
</li>
                    
   <p class="registrationFormAlert" style="color:#F00; font-size:16px; margin:3px;" id="divCheckPasswordMatch">
</p>

<p align="center"><input type="submit"   value="Sign up"  name="go"></p>


</ul>
</form>

Script:


function checkPasswordMatch() {
    var password = $("#txtNewPassword").val();
    var confirmPassword = $("#txtConfirmPassword").val();

    if (password != confirmPassword)
    {
     $("#divCheckPasswordMatch").html("Passwords do not match!  Try Again ") 
     document.oo.password2.focus();
     return false;
    }
        else
        {
    $("#divCheckPasswordMatch").html("Passwords match. GOOD");
    
        }
}

Thursday 19 September 2013

Create Folders in Bookmarks

index.php:
<body>
<p><a href="javascript:void(0)" onClick="return BookmarkApp.addBookmark(this)"> 
bookmark me</a></p>
 <br><br><br>
 </body>

Download js:Script

Current Timing By Using Javascript

Screenshot:
        
                                                     

index.php:


</head>
<body>
  <div class="datewidget">  
  <p ><span id=curTime></span></p>
  </div>
</body>

Style.css:


<style>
.datewidget 
{ font-size: 11px; 
    color: #999; 
    padding: 5px 10px;
    width:100px;
    border:1px solid #CCC;
}
</style>

script:


<script type="text/javascript">
function DisplayTime(){
if (!document.all && !document.getElementById)
return
timeElement=document.getElementById? document.getElementById("curTime"): document.all.tick2
var CurrentDate=new Date()
var hours=CurrentDate.getHours()
var minutes=CurrentDate.getMinutes()
var seconds=CurrentDate.getSeconds()
var DayNight="PM"
if (hours<12) DayNight="AM";
if (hours>12) hours=hours-12;
if (hours==0) hours=12;
if (minutes<=9) minutes="0"+minutes;
if (seconds<=9) seconds="0"+seconds;
var currentTime=hours+":"+minutes+":"+seconds+" "+DayNight;
timeElement.innerHTML="<font style='font-family:verdana, arial,tahoma;font-size:12px;color:#E25984; font-weight:bold;'>"+currentTime+"</b>"
setTimeout("DisplayTime()",1000)
}
window.onload=DisplayTime
</script>

Thursday 4 July 2013

PHP Cookies like Session

PHP Cookies:

1.Cookies->store the information->remote browser(web Page).
2.Same user->comes back to page->same information retrived again.

Uses of Cookies:

1.Session management:Manage Session User
2.User identification:Once the User Visits the web Page,that the user Can be Remembered.
3.Tracking / Analytics:Ieentify/Track the user.

Syntax for Create,Retrieve,Delete the Cookies:

Create->setcookie(name, value, expire, path, domain, secure, httponly)
Eg:
<?php
setcookie("myCookie", "PHP Tutorial", time()+3600, "/tutorials");
?>
Retrieve->
<?php
echo "The cookie value is ".$_COOKIE['myCookie'];
?>
Delete->
<?php
setcookie("myCookie", "", time()-60);
?>


Difference B/w Cookies&Session:

1.Both cookies and sessions are used for storing persistent data.
2.Sessions are stored->server side. Cookies->client side.
3.Sessions are closed when the user closes his browser. For cookies, you can set time that when it will be expired.
4.Sessions are safe that cookies. Because, since stored on client's computer, there are ways to modify or manipulate cookies.
5.Cookie is stored on your computer, and a session is not.


Tuesday 2 July 2013

Cake PHP in PHP Framework

Cake PHP Framework:
Cake PHP:
1.  CakePHP is a PHP based open-source framework 
developed for rapid web application development. 2. It’s a foundational structure for programmers to create web applications.
Our primary goal is to enable you to work in
a structured and rapid manner–without loss of flexibility. 3. CakePHP is consistently improving.

12 Reasons for to use Cake PHP:
1.  CakePHP is very easy to learn
2.  CakePHP developer community is very active and friendly
3.  It works with  PHP 4 and after
4.  Integrated CRUD (Create, Read, Update and Delete) for database interaction.
Instead of writing each CRUD operation by hand, it has prebuilt classes that do it for you 5. Code generation – Rapid development 6. Employees MVC architecture , thus enables clean separation between presentation,
business logic and back end 7. Request dispatcher with clean, custom URLs and
routes – Easy to build SEO friendly URLs 8. Built-in validation – No need to write your own code for
common validations such email, credit card etc 9. Fast and flexible templating (PHP syntax, with helpers) 10. View Helpers for AJAX, JavaScript, HTML Forms which enables a CakePHP developer
to write web application with rich user experience 11. In built components for Email, Cookie, Security, Session, and
Handling 12. Finally , you don't need an expensive hosting for CakePHP even
shared hosting will do just fine

Features of Cake PHP:
• Active, friendly community
• Flexible licensing
• Compatible with versions 4 and 5 of PHP
• Integrated CRUD for database interaction
• Application scaffolding
• Code generation
• MVC architecture
• Request dispatcher with clean, custom URLs and routes
• Built-in validation
• Fast and flexible templating (PHP syntax, with helpers)
• View Helpers for AJAX, JavaScript, HTML Forms and more
• Email, Cookie, Security, Session, and Request Handling Components
• Flexible ACL
• Data Sanitization
• Flexible Caching
• Localization
• Works from any web site directory, with
little to no Apache configuration involved

About PHP Framework

PHP Framework:

Framework:
     1.It’s an Interface between Application &OS.
     2.Collection of Classes,Applications&Libraries of SDKS&APIS to help the different Components 
all work together.
     3.It’s reusable set of libraries or classes for a software system(or sub system).


PHP Framework?
1.  This is a comparison of notable web application frameworks.
2.  PHP is the world’s most popular scripting language for many different reasons – flexibility,
 ease-of-use, among others – but often times coding in PHP, or
 any language for that matter,can get rather monotonous and repetitive. That’s 
wherea PHP frameworkcan help.
3.PHP frameworks streamline the the development of web applicationswritten in PHP by providing
 a basic structure for which to build the web applications.
4.  In other words, PHP frameworks help to promote rapid application development (RAD),
 which saves you time, helps build more stable applications, and reduces the amount of
 repetitive coding for developers.
5.  PHP framework is referred to as Model View Controller (MVC).
6.  MVC->Model refers to data, View refers to the presentation layer,and Controller to the
 application or business logic. 

Use a PHP Framework?
1.  Speeding.
2.  Reusing code 
3.  Stability.
4.  Simplicity.
5.  The availability of PHP frameworks is extensive


When to use a PHP Framework?
1.  It will help reduce or eliminate bad coding and speed up the build process.
2.  When working on a project with tight deadlines, utilizing a PHP framework is a huge benefit 
that can greatly speed up the coding process.
3.  when you’re working on projects with substantial amounts of monotonous coding,
because it will help make the job much less tedious.


What to Look for in a PHP Framework?
1.  Rapid development/performance
2.  Popularity amongst other developers
3.  Strong features
4.  Support/forums


Advantage of PHP Framework?
1.  Ease-of-use, features
2.   Support availability
3.  Scope of the community surrounding the framework
4.   Possible shortfalls.


Types PHP Framework?
There are 20 PHP Frame works:
1.  App Flower 2.ez Publish  3. CakePHP  4. CodeIgniter  5. Fat free6. Fuel PHP 
7. Horde 8.Joomla 9. Lithium 10. Miggard 11. Modx 
12. Qcodo 13. Seagull14. Symfony 15.Silverstripe 16. TYPo3 17. Xaraya 18. Zend 19. Zeta Components 20.Yii.
But the Top of them is 4 only:
1.Cake PHP  2.CodeIgniter 
3.Yii Framework 4.Zend Framework

Monday 1 July 2013

Hide Mobile&Email using PHP

Screenshot::
                    
index.php:

</head>
<body>
<?php echo substr("$email1", 0, 3) ?>***<?php echo substr("$email1", 13, 10) ?>| 
<?php echo substr("$mobile1", 0, 3) ?>****<?php echo substr("$mobile1", 7, 3) ?>
</body>
</head>
                   

Autocomplete Select Box Using Ajax,PHP,Mysql

Screenshot:
                          
index.php:

<html>
<head>
<title></title>
<link rel="stylesheet" href="autocomplete.css" type="text/css" media="screen">
<script src="jquery.js" type="text/javascript"></script>
<script src="dimensions.js" type="text/javascript"></script>
<script src="autocomplete.js" type="text/javascript"></script>

<script type="text/javascript">
    $(function(){
        setAutoComplete("searchField", "results", "action.php?part=");
    });
</script>
</head>

<body>
    <h1>Autocomplete Select Box using PHP,Ajax& MySQL</h1>
    <p id="auto">
        <label>Combinations: </label>
        <input id="searchField" name="searchField" type="text" />
    </p>    
    
</body>

</html>
        
action.php

<?php

$link = mysql_connect('localhost', 'root', '');
if (!$link) {
   die('Could not connect: ' . mysql_error());
}
if (!mysql_select_db("search_box")) {
   echo "Unable to select mydbname: " . mysql_error();
   exit;
}

$result = mysql_query("SELECT name FROM  sks_color");
while ($row = mysql_fetch_assoc($result)) {
        $colors[]=$row['name'];
}
mysql_free_result($result);
mysql_close($link);

// check the parameter
if(isset($_GET['part']) and $_GET['part'] != '')
{
    // initialize the results array
    $results = array();

    // search colors
    foreach($colors as $color)
    {
        // if it starts with 'part' add to results
        if( strpos($color, $_GET['part']) === 0 ){
            $results[] = $color;
        }
    }

    // return the array as json with PHP 5.2
    echo json_encode($results);
}

Download:js


Thursday 27 June 2013

Animation Using JS

Screen Shot:
                  
index.php:

<body>
<button>Click Me</button>
<p>Blogger Name</p>
<div style="border:1px solid #FFF; width:100px; height:20px; background-color:#CCC; position:absolute; box-shadow:0 0 2px 2px #CCC;">Creater Site</div>
</body>


Scripts:

<script>

$(document).ready(function() {
$("button").click(function(){

 $("div").animate({left:'250px', opacity:'',height:'60px',width:'100px'});

});
});
</script>
<script type="text/javascript" src="j.js">

Download:JS

Wednesday 26 June 2013

Draggable the object using JS

index.php:
 
<div id="draggable" class="ui-widget-content">
  <p>Drag me to my target</p>
</div>
 
<div id="droppable" class="ui-widget-header">
  <p>Drop here</p>
</div> 
 Script:
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
<script>
  $(function() {
    $( "#draggable" ).draggable();
    $( "#droppable" ).droppable({
      drop: function( event, ui ) {
        $( this )
          .addClass( "ui-state-highlight" )
          .find( "p" )
            .html( "Dropped!" );
      }
    });
  });
  </script>
Style:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" />
#draggable { width: 100px; height:100px;padding: 0.5em;float: left;margin: 10px 10px 10px 0;}
#droppable { width: 150px; height: 150px; padding: 0.5em; float: left; margin: 10px; }

Tuesday 25 June 2013

Convert a Form to as Zip File

Screenshot:
                        
index.php:

<body>
<form name="zips"  method="post">
<div >
<table width="600" border="0" align="center" cellpadding="10" cellspacing="0" 
style="border-collapse:collapse; border:#ccc 1px solid;" id="tbl">
  
  <tr>
    <td align="center"><input type="checkbox" name="files[]" value="for.php" /> 
<span> &nbsp;&nbsp;for.php</span></td>
  </tr>
  <tr><td align="center" colspan="2"><input type="submit" name="submit" 
value="create as zip" /></td></tr>
       </table>
</div>
</form>
</body>
   
form:

<?php
    
    if(isset($_POST['submit'])){
        $post = $_POST;     
        $file_folder = "files/";    
        if(extension_loaded('zip')){    
            if(isset($post['files']) and count($post['files']) > 0){    
                $zip = new ZipArchive();            
                $zip_name = time().".zip";          
                if($zip->open($zip_name, ZIPARCHIVE::CREATE)!==TRUE){       
                    $error .=  "* Sorry ZIP creation failed at this time<br/>";
                }
                foreach($post['files'] as $file){               
                    $zip->addFile($file_folder.$file);          
                }
                $zip->close();
                if(file_exists($zip_name)){
                    
            header('Content-type: application/zip');
            header('Content-Disposition: attachment; filename="'.$zip_name.'"');
                    readfile($zip_name);
                
                    unlink($zip_name);
                }
                
            }}
    }
?>
        
           

Monday 24 June 2013

Multiple Select Box in Static

index.php:

<body>
<form method="post" action="">
    <select name="php[]" multiple="multiple">
        <option value="PHP">PHP</option>
        <option value="Javascript">Javascript</option>
        <option value="Ajax">Ajax</option>
        <option value="Jquery">Jquery</option>
        <option value="HTML">HTML</option>
    </select> 
    <input type="Submit" value="Submit" />
</form>
</body>

Condition:

<?php if(!empty($_POST['php'])){
    for ($i=0; $i < count($_POST['php']);$i++) {
        echo $_POST['php'][$i] . ", ";
    }
}
?>