Translate

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