unable to pass values from include file
i need help with this page.
i got this from a book and was trying to make it work as i have to hand in a project.
the scripting was partially completed.
after successful login, it will come to the membersmenu.php but once it reach there it was being diverted back to the login page again.
the page relies on session values.
the values(userid,password) will be pass into the super global variables.
i have tried to echo out all the variables and found that i was not able to pass the $result from the include files out to the other function calls.
there is no value return from the getRow function call(dblib.inc) to the checkuser funtion(clublib.inc)
Any one knows why? i was stuck here the whoel day thinking abt it. PLEASE HELP!
i have highlighted in black in the membersmenu.php the code that makes the calling into the include file.
thanks.
membersmenu.php
===============
<?php
include("dblib.inc");
include("clublib.inc");
$club_row = checkUser(); // function call to clublib.inc
?>
<html>
<head>
<title>Welcome</title>
</head>
<body>
<?php include("publicnav.inc"); ?>
<h1>Members menu</h1>
<a href="updateclub.php?<?php print SID ?>">Review your club details</a><br>
<a href="reviewevents.php?<?php print SID ?>">Review your events</a><br>
<a href="updateevent.php?<?php print SID ?>">New event</a><br>
</body>
</html>
dblib.inc
=========
<?php
$link;
connectToDB();
function connectToDB()
{
global $link;
$Name = "Organizer";
$link = mysql_connect( "localhost");
if ( ! $link )
die( "Couldn't connect to MySQL" );
mysql_select_db( $Name, $link )
or die ( "Couldn't open organizer: ".mysql_error() );
}
function getRow( $table, $fnm, $fval )
{
global $link;
$result = mysql_query( "SELECT * FROM $table WHERE $fnm='$fval'", $link );
if ( ! $result )
die ( "getRow fatal error: ".mysql_error() );
return mysql_fetch_array( $result );
}
?>
clublib.inc
=========
<?
session_start();
session_register( "session" );
function cleanMemberSession( $id, $login, $pass )
{
global $session;
$_SESSION['id'] = $id;
$_SESSION['login'] = $login;
$_SESSION['password'] = $pass;
$_SESSION['logged_in'] = true;
}
function checkUser( )
{
global $session, $logged_in;
$_SESSION['logged_in'] = false;
$club_row = getRow( "clubs", "id", $_SESSION['id'] );
if (! $club_row || $club_row['login'] != $_SESSION['login'] || $club_row['password'] != $_SESSION['password'])
{
header( "Location: login.php" );
exit;
}
return $club_row;
}
?>
|