By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,889 Members | 1,044 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,889 IT Pros & Developers. It's quick & easy.

i'm confused and don't know what to do

P: 20
i have developed a log in system which is a starting point for my online learning system i'm developing.
i'm failing to log in possibly the system is not able to register a user as a valid user.The system is not reflecting error warnings.
Here is a code section where i'm suspecting a fault.


function login($username, $passwd)
// check username and password with db
// if yes, return true
// else return false
{
// connect to db
$conn = db_connect();
if (!$conn)
return 0;

// check if username is unique
$result = mysql_query("select * from users
where username = '$username'
and passwd = '$passwd'");
if (!$result)
return 0;

if (mysql_num_rows($result)>0)
return 1;
else
return 0;
}

function check_valid_user()
// see if somebody is logged in and notify them if not
{
global $valid_user;
if (session_is_registered("valid_user"))
{
echo "Logged in as $valid_user.";
echo "<br>";
}
else
{
// they are not logged in
do_html_heading("Problem:");
echo "You are not logged in.Please try again.<br>";
do_html_url("login.php", "Login");
//do_html_footer();
exit;
}
}


<?
session_start();
// include function files for this application
require_once("system_fns.php");
if (isset($username) && isset($passwd))
// they have just tried logging in
{
if (login($username, $passwd))
{
// if they are in the database register the user id
$valid_user = $username;
session_register("valid_user");
}
}
check_valid_user();
// give menu of options
display_user_menu();
?>


Please help to get out of this situation
Feb 14 '07 #1
Share this Question
Share on Google+
1 Reply


ronverdonk
Expert 2.5K+
P: 4,258
Please read the Posting Guidelines before you post in this forum!.
Especially the part about enclosing posted code within code or php tags!

moderator
Feb 14 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.