17-mysql_database/common_functions.php File Reference

This file is not intended to be run / executed directly from browser. More...

Go to the source code of this file.

Functions

 connect_to_database ()
 This function is used to connect to mysql server and use database.
 create_random_image ()
 It is used to create random image.
 get_post ($variable)
 Following function is used to get post variable.
 get_remote_address ()
 It is used to find proper i.p.
 get_server ($variable)
 Following function is used to get server variables.
 get_session ($variable)
 Following function is used to get session variable.
 redirect ($page)
 This function is used to redirect the user to given page.


Detailed Description

This file is not intended to be run / executed directly from browser.

This file contains definitions of functions which can be used in many different pages.

Author:
Saurabh Barjatiya
Version:
1.0

Definition in file common_functions.php.


Function Documentation

connect_to_database (  ) 

This function is used to connect to mysql server and use database.

Values for Username, password, database name, database server address are taken from constants DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_DBNAME and DATABASE_HOST respectively. if error occurs then this function displays proper error message and stops execution of script.

Returns:
Database connection in which we have already selected a database to work on after connection to database server

Definition at line 146 of file common_functions.php.

Referenced by address_book_page(), and main().

create_random_image (  ) 

It is used to create random image.

It stores the random number displayed in image in session variable 'verification_code'. It generates image named IMAGE_FILENAME. Web server must have write permissions on folder where image is to be created for this to work. Also php-gd package must be installed for the image manipulation functions to work. This function uses constants IMAGE_MINIMUM_NUMBER, IMAGE_MAXIMUM_NUMBER, IMAGE_CUTS, IMAGE_FONT_SIZE, IMAGE_SPACING, IMAGE_NUMBER_OF_CHARS, IMAGE_FILENAME, etc. for its operations.

Definition at line 98 of file common_functions.php.

References $_SESSION.

Referenced by address_book_page().

get_post ( variable  ) 

Following function is used to get post variable.

If it does not exist then it returns empty string. But no warning or error is generated.

Parameters:
$variable Name of the variable to be retrieved. It must be passed as string.
Returns:
Value of POST variable with given name. It returns blank if no variable with given name was submitted.

Definition at line 79 of file common_functions.php.

get_remote_address (  ) 

It is used to find proper i.p.

address of client. It returns proper i.p. address even if the client is connected through proxy server.

Definition at line 42 of file common_functions.php.

References $remote_address, and get_server().

Referenced by main().

get_server ( variable  ) 

Following function is used to get server variables.

If it does not exist then it returns empty string. But no warning or error is generated.

Parameters:
$variable Name of the variable to be retrieved. It must be passed as string.
Returns:
Value of SERVER variable with given name. It returns blank if no variable with given name was submitted.

Definition at line 29 of file common_functions.php.

get_session ( variable  ) 

Following function is used to get session variable.

If it does not exist then it returns empty string. But no warning or error is generated.

Parameters:
$variable Name of the variable to be retrieved. It must be passed as string.
Returns:
Value of session variable of given name. If no such variable exists, it returns blank.

Definition at line 62 of file common_functions.php.

References $_SESSION.

redirect ( page  ) 

This function is used to redirect the user to given page.

It redirects using META-REFRESH with time interval seconds.

Parameters:
page Page relative to current page where user should be redirected.

Definition at line 171 of file common_functions.php.

References redirect().


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