•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 422,408 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,922 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 418 | Replies: 10
![]() |
•
•
Join Date: May 2008
Posts: 32
Reputation:
Rep Power: 1
Solved Threads: 0
The following login script is not working, i am unable to trace the problem, please anybody help me...
thanks in advance..
<?php
include ("template/login.tpl.htm");
session_start();
if (isset($_POST['userid']) && isset($_POST['userpassword'])) {
include 'library/config.php';
include 'library/opendb.php';
$userId = $_POST['userid'];
$password = $_POST['userpassword'];
// check if the user id and password combination exist in database
$sql = "SELECT user_id,user_password
FROM tbl_auth_user
WHERE user_id = '$userId' AND user_password = PASSWORD('$password')";
$result = mysql_query($sql) or die('Query failed. ' . mysql_error());
if (mysql_num_rows($result)==1) {
// the user id and password match,
// set the session
$_SESSION['db_is_logged_in'] = true;
$_SESSION['userid']= $userId;
// after login we move to the main page
header('Location: index.php');
exit;
} else {
echo "Sorry, wrong user id / password";
echo "$sql";
}
include 'library/closedb.php';
}else {
echo "please supply your id and password";
}
?>thanks in advance..
•
•
Join Date: May 2008
Location: Hyderabad,India
Posts: 89
Reputation:
Rep Power: 1
Solved Threads: 0
•
•
Join Date: May 2008
Location: Hyderabad,India
Posts: 89
Reputation:
Rep Power: 1
Solved Threads: 0
Try this:
and session.php is
include("session.php");
$userId = $_POST['userid'];
$password = $_POST['userpassword'];
$sql = "SELECT user_id,user_password
FROM tbl_auth_user WHERE user_id = '$userId' AND user_password = '$password'";
$res=mysql_query($str);
if(mysql_num_rows($res)!=0)
{
$_SESSION['userId']=$userId;
header("location:nextpage.php");
}
else
header("location:login.php");
?><?php
session_start();
if($_SESSION['userId']=='')
header("Location:login.php");
?> Suhasini
•
•
Join Date: May 2008
Location: Hyderabad,India
Posts: 89
Reputation:
Rep Power: 1
Solved Threads: 0
•
•
Join Date: May 2008
Location: Hyderabad,India
Posts: 89
Reputation:
Rep Power: 1
Solved Threads: 0
•
•
Join Date: May 2008
Location: Hyderabad, India
Posts: 13
Reputation:
Rep Power: 1
Solved Threads: 2
write the query like this
PHP Syntax (Toggle Plain Text)
$sql = "SELECT user_id,user_password FROM tbl_auth_user WHERE user_id = '".$userId."' AND user_password = PASSWORD('".$password."')";
Last edited by peter_budo : Jun 4th, 2008 at 3:51 am. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Dec 2007
Location: Oklahoma
Posts: 161
Reputation:
Rep Power: 1
Solved Threads: 16
Suhacini's code looks good but a small typo i think
change to:
php Syntax (Toggle Plain Text)
$res=mysql_query($str);
change to:
php Syntax (Toggle Plain Text)
$res=mysql_query($sql);
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
age amd avatar blue gene business chips database development dos economy energy enterprise environment hardware ibm ibm. news intel ibm it linux medicine memory microsoft news office open source openoffice pc ps3 recession red hat remote working russia security sex sun supercomputer supercomputing technology trends ubuntu working x86
- Setting up a form in PHP (PHP)
- Error: "Use of undefined constant" Help! (PHP)
- login box not working (JavaScript / DHTML / AJAX)
- Help with vbs code for login script (VB.NET)
- Can't get samba to work! (*nix Software)
- session (PHP)
- Entering a session without the browser login. (PHP)
- how to make member expire after so many days with php script (PHP)
- limiting account names (PHP)
Other Threads in the PHP Forum
- Previous Thread: for loop inside if statement
- Next Thread: stop a process using php


Linear Mode