Advertisement
Guest User

Freakforum

a guest
May 11th, 2014
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1. <?php
  2.     session_start ( );
  3.  
  4.     header ( "Content-type: text/html" );
  5.  
  6.     if ( isset ( $_SESSION [ "views" ] ))
  7.     {
  8.         if ( empty ( $_SESSION [ "views" ] ) || $_SESSION [ "views" ] == false )
  9.         {
  10.             $_SESSION [ "views" ] = 0;
  11.         }
  12.  
  13.         if ( isset ( $_POST [ "stopcount" ] ) && $_POST [ "stopcount" ] == 1 )
  14.         {
  15.             session_destroy ( );
  16.  
  17.             header ( "Location: http://localhost/mer-php/neocounter.php" );
  18.         }
  19.  
  20.         $_SESSION [ "views" ] ++;
  21.     }
  22.     else
  23.     {
  24.         $_SESSION [ "views" ] = 1;
  25.     }
  26. ?>
  27.  
  28. <html>
  29.     <head>
  30.         <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  31.         <title>Besøks teller</title>
  32.     </head>
  33.     <body>
  34.         <span>Antall besøk: <?php echo isset ( $_SESSION [ "views" ] ) ? $_SESSION [ "views" ] : 0 ; ?></span>
  35.  
  36.         <form action="" method="post">
  37.             <input type="checkbox" name="stopcount" value="1"><span>Ja, nullstill</span>
  38.             <input type="submit" value="send inn">
  39.         </form>
  40.  
  41.     </body>
  42. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement