Hi,
1. I have a common.php file asking php to include database.php;
Here is the code snippet:
<?php
// Include Server Class
//include $_SERVER['DOCUMENT_ROOT'].'/includes/session.php';
// Include Meta Content Class
include $_SERVER['DOCUMENT_ROOT'].'/classes/clsMetaContent.php';
// Include Email Class
include $_SERVER['DOCUMENT_ROOT'].'/classes/clsEmail.php';
// Include Database Connection File
include $_SERVER['DOCUMENT_ROOT'].'/includes/database.php';
?>
- My layout.php file has a function to create the header functions and includes the common.php .....
Code snippet:
<?php
function myheader($ptitle){
include $SERVER['DOCUMENT_ROOT']."/common.php";
// Include the welcome html page.
include $SERVER['DOCUMENT_ROOT'].'/html/index_page.html';
.....
- Now, In my login script, I use the layout.php file and create a login session:
Unless I explicitly open the database again with a my_sql_sellect_db, the code trows up an error on the mysql_fetch_assoc, not on the mysql_query which comes first!!!!
Code Snippet:
<?php
include $_SERVER['DOCUMENT_ROOT'].'/layout.php';
//some reason demands explicit database connection here to work right
mysql_select_db('myRestaurant', mysql_pconnect('localhost', 'root', 'passwd'))
or die (mysql_error());
if (isset($SESSION))
{
print $SESSION['FirstName'];
session_destroy();
}
//Does Not let me move this to a separate file for elegance!
//Need to figure out why
session_start();
session_name('RestaurantManager');
header("Cache-control: private"); // Fix for IE
//Debug Tool
//printf("MySQL host info: %s\n", mysql_get_host_info());
switch($_REQUEST['req']){
case "validate":
//print_r($POST);
//$temp = md5($POST['Password']);
//echo $temp;
$validatelogin = @("SELECT * FROM mylogin
WHERE LogId='{$POST['LogId']}' AND
Password = md5('{$POST['Password']}')
");
//echo 'Validated ' ;
//echo "Printing Data \n\n";
$row = mysql_fetch_assoc($validatelogin);
//echo $row['LogId'];