Posts

#101. PHP Session

Image
 How to Create, View and Delete  PHP Session? Create-Session.php <?php     session_start() ;     $_SESSION [ "favcolor" ] = "orange" ;     echo "Session Variable is set." ; ? > View-Session.php <?php session_start() ; print_r($_SESSION) ; ? > <!DOCTYPE html > <html lang = "en" > <head>     <meta charset = "UTF-8" >     <title></title> </head> <body>     <?php         if (isset($_SESSION [ "favcolor" ] )){             echo "Favorite Color :" . $_SESSION [ "favcolor" ];         }     ? > </body> </html> Delete-Session.php <?php session_start() ; session_unset() ; session_destroy() ; echo "Session is destroy." ; ? >

#100. PHP COOKIE

Image
 How to create, view and expired cookies.? Create Cookie form: <?php $cookie_name = "user" ; $cookie_value = "Sheikh Aqib" ; setcookie($cookie_name , $cookie_value , time() + ( 86400 * 30 ) , "/" ) ; ? > <html> <body>     <?php         if ( ! isset($_COOKIE [ $cookie_name ] )){             echo "Cookie is not set" ;         } else {             echo $_COOKIE [ $cookie_name ];         }     ? > </body> </html> View Cookie form: <?php  echo "Cookie Value :" . $_COOKIE [ "user" ];     // Delete the cookie  setcookie( "user" , "" , time() - ( 86400 * 30 ) , "/" ) ; ? >

#99. PHP $_SERVER

Image
 How to Show data won page. Run Code: <!DOCTYPE html > <html> <head>     <title> Simple Form </title> </head> <body>         <form action = " <?php echo $_SERVER [ 'PHP_SELF' ] ? > " method = "post" >           Name : <input type = "text" name = "fname" ><br><br>         Age : <input type = "text" name = "age" ><br><br>         <input type = "submit" name = "save" >     </form>     <?php         if (isset($_POST [ 'save' ] ))         {             echo $_POST [ 'fname' ] . "<br>" ;             echo $_POST [ 'age' ] . "<br>" ;         }       ? > </body> </html> O/P

#98. PHP GET POST REQUEST Function

Image
How to work PHP GET POST REQUEST Function? Form 2: // on another file Execute  <!DOCTYPE html > <html> <head>     <title> Simple Form </title> </head> <body>     <form action = "f2GetPostRequest.php" method = "post" >  //get , post, request         Name : <input type = "text" name = "fname" ><br><br>         Age : <input type = "text" name = "age" ><br><br>         <input type = "submit" name = "save" >     </form> </body> </html> Form 2: <?php echo "<pre>" ; print_r($_POST) ; echo "</pre>" ; echo $_POST [ 'fname' ]; ? >

#97. PHP Include_once & Require_once

Image
How to Create PHP Include_once & Require_once? Code: form.php <!DOCTYPE html > <html> <head>     <title> Page Layout </title>     <style>         .sidebar {   height : 100 % ;   width : 200 px ;   position : fixed ;   z-index : 1 ;   top : 0 ;   left : 0 ;   background-color : #111 ;   overflow-x : hidden ;   padding-top : 20 px ; } .sidebar a {   padding : 6 px 6 px 6 px 32 px ;   text-decoration : none ;   font-size : 25 px ;   color : #818181 ;   display : block ; } .sidebar a:hover {   color : #f1f1f1 ; }         .head1 {             font-size : 40 px ;             color : #009900 ;             font-weight : bold ;         }         .head2 {     ...