Everytime a genuine user logs into the website we create a session object, which stores his userID.
Every page a user visits logging in to the wesite, should have a session check at the begining of each page. This is done by a function sessionExists().
This function checks if the session object is created for the particular user. If the session is created it will return true, else it will just redirect the user to the home page of this website.
Function: sessionExists()
Defination:
function sessionExists(){
//start the session session_start();
if(!session_is_registered('userID'))
{
//the session variable isn't registered, send them back to the login page
header( "Location: http://discern.uits.iu.edu:8490/UI/index.php" );
}
else {return true;}
}
Usage:
include("../modules/login_func.php");
if (sessionExists())
{
//your page
}
Wednesday, February 20, 2008
Saturday, February 9, 2008
Including a Java Script File
<html>
<head>
<script type="text/javascript" src="file.js"></script>
</head>
</html>
Please don't use the shortcut <script type="text/javascript" src="file.js" />
This causes problems with Internet Explorer 6, which doesn't load the JavaScript page.
Once you include the javascript file, it executes automatically when you load the HTML file. You can also group the code in JavaScript functions, which only executes when called explicitly(This is what we will be doing most of the time).
<head>
<script type="text/javascript" src="file.js"></script>
</head>
</html>
Please don't use the shortcut <script type="text/javascript" src="file.js" />
This causes problems with Internet Explorer 6, which doesn't load the JavaScript page.
Once you include the javascript file, it executes automatically when you load the HTML file. You can also group the code in JavaScript functions, which only executes when called explicitly(This is what we will be doing most of the time).
Friday, February 8, 2008
Structure of a Users Page
<?php
include("unregistered/header1.php");
?>
<title>Innes Lab::(Name of the Page)</title>
<?php
include("user/userheader2.php");
?>
<body>
<?php
include("user/userLinks.php");
This file will change depending on the which link you want to be active. Make sure use change the hrefs appropriately.
include("unregistered/banner.php");
?>
<div id="page">
This is where you will show, whatever you want to show to the user.
An Example of this structure can be found at http://discern.uits.iu.edu:8490/UI/userHomePage.php
</div>
<?php
include ("unregistered/footer.php");
?>
include("unregistered/header1.php");
?>
<title>Innes Lab::(Name of the Page)</title>
<?php
include("user/userheader2.php");
?>
<body>
<?php
include("user/userLinks.php");
This file will change depending on the which link you want to be active. Make sure use change the hrefs appropriately.
include("unregistered/banner.php");
?>
<div id="page">
This is where you will show, whatever you want to show to the user.
An Example of this structure can be found at http://discern.uits.iu.edu:8490/UI/userHomePage.php
</div>
<?php
include ("unregistered/footer.php");
?>
Structure of Administrator's page
The System administrator pages has slightly different page structure.
<?php
include("header1.php");
?>
<title>InnesLab::Administrator</title>
<?php
include("admin/adminheader2.php");
?>
<body>
<?php
include("admin/adminBanner.php");
include("admin/adminLinksUsersSelected.php");
The link file are the navigation link for the administrator. The links are highlighted to indicate the current section the administrator is looking at.
The example shown above will have the USER link highlighted. I have made separate include files for different links.
So, for highlighting Admin Accounts, include adminLinksAdminAccountsSelected.php.
All the UI files for the administrator are grouped in to the UI/admin folder.
An Example of such implementation is
http://discern.uits.iu.edu:8490/UI/adminEditUser.php
?>
<div id="page">
What ever you want to display comes here. Take help from my html pages the I have up uploaded in the UI section. These files have .html extension, but whatever you make should have an .php extension.
<?php
include ("footer.php");
?>
<?php
include("header1.php");
?>
<title>InnesLab::Administrator</title>
<?php
include("admin/adminheader2.php");
?>
<body>
<?php
include("admin/adminBanner.php");
include("admin/adminLinksUsersSelected.php");
The link file are the navigation link for the administrator. The links are highlighted to indicate the current section the administrator is looking at.
The example shown above will have the USER link highlighted. I have made separate include files for different links.
So, for highlighting Admin Accounts, include adminLinksAdminAccountsSelected.php.
All the UI files for the administrator are grouped in to the UI/admin folder.
An Example of such implementation is
http://discern.uits.iu.edu:8490/UI/adminEditUser.php
?>
<div id="page">
What ever you want to display comes here. Take help from my html pages the I have up uploaded in the UI section. These files have .html extension, but whatever you make should have an .php extension.
<?php
include ("footer.php");
?>
Monday, February 4, 2008
Writing a function
Hi,
I have created a function to display the list of all the projects in the system.
This is the getAllProjects() function from our system architecture.
Since it belongs to the "Project Browsing" module. I have created a folder called "project browsing" which has a file called functions.php. functions.php will defination for all the functions that belong to this module.
Before we start any new function we can write a short description about the function. Example:
/*#########################################
Author:your name
Date:02/04/2008
Description:This functions displays the list of all the projects on the website.
It is called by all the pages that need list of projects to be displayed.
###########################################*/
function getAllProjects()
{
....
....
....
}
We can copy paste the Description of a function from our excel sheet.
The page that calls this function is viewListOfAllProjects.phphttp://discern.uits.iu.edu:8490/viewListOfAllProjects.php
Please, look at the code and tell me, if you like my coding style. If you don't like it then we can change it to something thats more easy to understand. But, Please do not change the php file.
A common coding style will help our code to be consistent.
I have not commented the code very well, but i guess, it should be easy to understand.
Thank you,
I have created a function to display the list of all the projects in the system.
This is the getAllProjects() function from our system architecture.
Since it belongs to the "Project Browsing" module. I have created a folder called "project browsing" which has a file called functions.php. functions.php will defination for all the functions that belong to this module.
Before we start any new function we can write a short description about the function. Example:
/*#########################################
Author:your name
Date:02/04/2008
Description:This functions displays the list of all the projects on the website.
It is called by all the pages that need list of projects to be displayed.
###########################################*/
function getAllProjects()
{
....
....
....
}
We can copy paste the Description of a function from our excel sheet.
The page that calls this function is viewListOfAllProjects.phphttp://discern.uits.iu.edu:8490/viewListOfAllProjects.php
Please, look at the code and tell me, if you like my coding style. If you don't like it then we can change it to something thats more easy to understand. But, Please do not change the php file.
A common coding style will help our code to be consistent.
I have not commented the code very well, but i guess, it should be easy to understand.
Thank you,
MySQLi Problem
Hi,
Rajesh has solved the database connection problem. Well, the reason why we were not able to connect to the database is that, the uits webserver has a new version of MySQL, that is MySQLi ('i' Stands for improved). The syntax of MySQLi and MySQL is slightly different so we need to make sure that we get the syntax right.
more information about mysqli can be found at http://us.php.net/mysqli
Rajesh has solved the database connection problem. Well, the reason why we were not able to connect to the database is that, the uits webserver has a new version of MySQL, that is MySQLi ('i' Stands for improved). The syntax of MySQLi and MySQL is slightly different so we need to make sure that we get the syntax right.
more information about mysqli can be found at http://us.php.net/mysqli
Structure of the webpage
include ("header1.php");
<title>Innes Lab::(name of the page)</title>
include ("header2.php");
<body>
include links.php
(our web site has different set of links for different purpose. So make sure you include the correct link file. I will be making the link files for the possible links. Thus if you don't find link file for your module, then please contact me)
include ("banner.php");
<div id="page">
write what ever you want to display here.
</div>
include ("footer.php");
An example of this structure is test.php(its on the web server). Please refer to this file, to understand the structure of the webpage.
Administrator module will need a different banner, ..so I will send another banner for administrator pretty soon.
Use the <div id="page">
....
</div> section to display all the information to the user.
Please let me know if you have any problems with this.
<title>Innes Lab::(name of the page)</title>
include ("header2.php");
<body>
include links.php
(our web site has different set of links for different purpose. So make sure you include the correct link file. I will be making the link files for the possible links. Thus if you don't find link file for your module, then please contact me)
include ("banner.php");
<div id="page">
write what ever you want to display here.
</div>
include ("footer.php");
An example of this structure is test.php(its on the web server). Please refer to this file, to understand the structure of the webpage.
Administrator module will need a different banner, ..so I will send another banner for administrator pretty soon.
Use the <div id="page">
....
</div> section to display all the information to the user.
Please let me know if you have any problems with this.
Subscribe to:
Posts (Atom)