14-session_variables/welcome.php

Go to the documentation of this file.
00001 <?php
00012 //When using sessions we must start session as early in program
00013 //as possible, preferably first line.
00014 session_start();
00015 
00018 session_register('logged_in');
00019 
00020 
00021 //including file which has common functions like redirect
00022 //and get_session which will be reused in many scripts
00023 require('common_functions.php');
00024 
00025 
00026 
00032 function show_welcome_page()
00033 {
00034     ?>
00035         <html>
00036             <head>
00037                 <title>Welcome Page<title>
00038             </head>
00039             <body>
00040                 <h3>Welcome <?php echo htmlspecialchars(get_session('logged_in')); ?></h3>
00041                 <br/>
00042                 <br/>
00043                 Click<a href="logout.php">here</a> to logout
00044             </body>
00045         </html>
00046     <?php
00047 }
00048 
00049 
00057 function main()
00058 {
00059     //Check for logged in user.
00060     $username1=get_session('logged_in');
00061     if($username1=="")
00062     {
00063         //If no one is logged in then redirect to index.php page
00064         redirect('index.php');
00065     }
00066     else
00067     {
00068         //If some user is logged in show welcome page.
00069         show_welcome_page();
00070     }
00071 }
00072 
00073 
00074 main();
00075 
00076 ?>

Generated on Fri Nov 4 14:16:54 2011 for PHP example documentation by  doxygen 1.4.7