14-session_variables/index.php File Reference

This page demonstrates use of SESSION variables to keep track of user session. More...

Go to the source code of this file.

Functions

 get_post ($var1)
 This function returns value of POST variable whose name is given as argument.
 main ()
 This is where program execution starts.
 show_login_page ()
 This function displays login page which prints value of global variable message, followed by form for entering username and password.

Variables

 $message = ''
 Will be used to pass message to show_login_page() to be displayed at top of login form.


Detailed Description

This page demonstrates use of SESSION variables to keep track of user session.

This page will display login form and if username and password 'match' it redirects to welcome page.

Author:
Saurabh Barjatiya
Version:
1.0

Definition in file index.php.


Function Documentation

get_post ( var1  ) 

This function returns value of POST variable whose name is given as argument.

If variable is not set it returns empty string "" as variable value.

Parameters:
var1 Name of variable whose value should be searched in POST array
Returns:
Value of variable in POST array. It returns empty string if variable is not present in POST array.

Definition at line 39 of file index.php.

main (  ) 

This is where program execution starts.

It checks if user is already logged in or not. If user is already logged in this page redirects to welcome.php page. If user is not logged in then it checks whether form was submitted or is being displayed for first time. If form is being displayed for first time it simply calls show_login_page() to display form. If form was submitted it redirects to welcome page if username and password match after setting proper session values, otherwise it displays login form again with message 'Username and password do not match'.

Returns:
Nothing.

Definition at line 88 of file index.php.

References $_SESSION, $message, get_post(), get_session(), redirect(), and show_login_page().

show_login_page (  ) 

This function displays login page which prints value of global variable message, followed by form for entering username and password.

Returns:
Nothing

Definition at line 55 of file index.php.

References $message.


Variable Documentation

$message = ''

Will be used to pass message to show_login_page() to be displayed at top of login form.

Definition at line 27 of file index.php.


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