March 2012 ~ ScriptsSnippets

Monday, 5 March 2012

Two Flower VLC Media Player

Two Flower VLC Media Player

  •  VLC Releases its newer version of its Popular Media Player,the Two Flower VLC Media Player.
  • With faster decoding on multi-core, GPU, and mobile hardware and the ability to open more formats, notably professional, HD and 10bits codecs, 2.0 is a major upgrade for VLC.
  • Twoflower has a new rendering pipeline for video, with higher quality subtitles, and new video filters to enhance your videos.
  • It supports many new devices and BluRay Discs (experimental)
  • Two Flower Fixes Sevral Hundred Bugs
  • And After all that its free,portable and supported on all Platforms
  • Download Link :http://www.videolan.org/vlc/releases/2.0.0.html
Thank u for reading this  Article hope it was useful !
-Regards
ScriptsSnippets


PHP Session

PHP Session


  • A cookie recides on the users web Browser and may be suited for storing small amount of information and for limited concern on security.
  • When we need to store a considerable amount of information we use session and we have a Security advantage of session being stored on the web server itself which is more secure than a Cookie on the User's Browser.
  • PHP allows us to use Sessions by a Session Variable which is a 'Super Global' , It holds information about a Single User.
  • Sessions create a Unique Id for each Visitor and stores variables based on this UID



SESSION START
  • First we must start up a Session before using it to store User's Information
Session Start Snippet




<?php session_start(); ?>

<html>
<body>

</body>
</html>


Note:The session_start() function should be included before outputting any HTML content


SESSION VARIABLE


  • A Session variable is created by the variable $_SESSION
  • We can assign any name to a Session variable
      Session Variable Snippet

<?php
session_start();
// store session data
$_SESSION['name’]=”sathesh”;
?>

<html>
<body>

<?php
//retrieve session data
echo "The Author of ScriptsSnippets is=". $_SESSION['name'];
?>

</body>
</html>
Output:
The Author of ScriptsSnippets is Sathesh
 

SESSION DESTROY

  • If you want to unset a particular Session variable we can use the unset() function to remove the value from the session variable
Unsetting a variable Snippet

<?php
unset($_SESSION['name']);
?>


  • When you do not need any of your Session variable and our aim is to completely destroy the session then we use session_destroy() function.
Session Destroy Snippet

<?php
session_destroy();
?>


 Thank u for reading this  Article hope it was useful !
-Regards
ScriptsSnippets




Saturday, 3 March 2012

Login Logout Snippet PHP

PHP Login validation and logout Snippet



Login.php
  • This is the login HTML page wit a Username and Password text field and a submit button

   <form action="verify.php" method="post" >
  <tr>
    <td>UserName :</td><td><input type="text" name="username"      value=""/></td></tr>
    <tr>
  <td>Password:</td><td><input type="password" name="password" value="" /></td></tr>
  <tr><td /><td><input type="submit" name="login" value="Login" /></td></tr>
 </form>
 




Verify.php

  • This is the PHP script specified in the Form Action of the HTML Page,whose primary purpose is to authenticate a user is a verified user or not.

<?php 
if(isset($_POST['login'])){ 
    $dbHost = "localhost";        //Location Of Database usually its localhost 
    $dbUser = "root";            //Database User Name 
    $dbPass = "";            //Database Password 
    $dbDatabase = "";    //Database Name 
     
    $db = mysql_connect($dbHost,$dbUser,$dbPass)or die("Error connecting to database."); 
    //Connect to the databasse 
    mysql_select_db($dbDatabase, $db)or die("Couldn't select the database."); 
    //Selects the database 
     
    The Above code can be in a different file, then you can place include'filename.php'; instead.
   
    $usr = mysql_real_escape_string($_POST['username']); 
    $pas = mysql_real_escape_string($_POST['password']); 
    $sql = mysql_query("SELECT * FROM login  
        WHERE username='$usr' AND 
        password='$pas' 
        LIMIT 1"); 
    if(mysql_num_rows($sql) == 1){ 
        $row = mysql_fetch_array($sql); 
        session_start(); 
        $_SESSION['username'] = $row['username']; 
        $_SESSION['logged'] = TRUE; 
  
  echo "Login Successful";
        // Modify to go to the page you would like 
        exit; 
    }else{ 
 $_SESSION['logged']= FALSE;
 echo "Login Failed";
                exit; 
    } 
}else{    //If the form button wasn't submitted go to the index page, or login page 
    header("Location: index.html");     
    exit; 
} 
?> 

Logout.php
  • This is the logout PHP Script used to unset and destroy the created Session

<?php
 //Start session
 session_start();
 //Unset the variables stored in session
 unset($_SESSION['username']);
 unset($_SESSION['logged']);
 session_destroy();
 //unset($_SESSION['SESS_LAST_NAME']);
?>
  • Note: Start the session again before destroying the variables in the logout page else an error will be specified
Include these in the your html pages you need to use.Cheers !

Thank u for reading this  Article hope it was useful !
-Regards
ScriptsSnippets

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Web Hosting Coupons