- <?php
-
//Start session
-
session_start();
-
-
//Include database connection details
-
require_once('config.php');
-
-
//Array to store validation errors
-
$errmsg_arr = array();
-
-
//Validation error flag
-
$errflag = false;
-
-
//Connect to mysql server
-
$link = mysql_connect("localhost","root","");
-
if(!$link) {
-
die('Failed to connect to server: ' . mysql_error());
-
}
-
-
//Select database
-
$db = mysql_select_db("shekhar");
-
if(!$db) {
-
die("Unable to select database");
-
}
-
-
//Function to sanitize values received from the form. Prevents SQL injection
-
function clean($str) {
-
$str = @trim($str);
-
if(get_magic_quotes_gpc()) {
-
$str = stripslashes($str);
-
}
-
return mysql_real_escape_string($str);
-
}
-
-
//Sanitize the POST values
-
$login = clean($_POST['login']);
-
$password = clean($_POST['password']);
-
-
//Input Validations
-
if($login == '') {
-
$errmsg_arr[] = 'Login ID missing';
-
$errflag = true;
-
}
-
if($password == '') {
-
$errmsg_arr[] = 'Password missing';
-
$errflag = true;
-
}
-
-
//If there are input validations, redirect back to the login form
-
if($errflag)
-
{
-
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
-
session_write_close();
-
header("location: index.php");
-
exit();
-
}
-
-
//Create query
-
$qry="SELECT * FROM members WHERE login='$login' AND passwd='".md5($_POST['password'])."'";
-
$result=mysql_query($qry);
-
-
//Check whether the query was successful or not
-
if($result)
-
{
-
if(mysql_num_rows($result) == 1)
-
{
-
//Login Successful
-
session_regenerate_id();
-
$member = mysql_fetch_assoc($result);
-
$_SESSION['SESS_MEMBER_ID'] = $member['member_id'];
-
$_SESSION['SESS_FIRST_NAME'] = $member['firstname'];
-
$_SESSION['SESS_LAST_NAME'] = $member['lastname'];
-
session_write_close();
-
header("location: member-index.php");
-
exit();
-
}
-
else
-
{
-
//Login failed
-
header("location: login-failed.php");
-
exit();
-
}
-
}
-
-
-
else
-
{
-
die("Query failed");
-
}
-
?>
8 5923
What's your question? which part of the code is causing the issue? Does it currently work? Throw errors?
DM
my ques is, i want the login page to be redirected to two different page as per user, if admin login it will show the different page and if user login it will show the different page.i m checking the login detail with the stored database.ya this code is working fine.
OK, so your line where it says redirect, you just put some logic there. - if ($admin) {
-
redirect to admin page
-
} else
-
redirect to user page
-
}
How you check for admin is up to you. I suggest another field in your database to say that user123 is admin or not. If you have one admin user always and forever, then create a user with user_id = 1 and login name to be "admin". Check the user_id and login to see if this is admin.
Advise: Don't store the admin flag in the SESSION, always check the database every time you want to know a user is admin. This way someone can't hijack your session and set this variable themselves. (This can easily be done).
Dan
Sweet and discreet, this one speed mini bullet vibe features a built-in finger ring for pinpointing pleasure, a waterproof body for aquatic enjoyment, and a shiny metallic finish for eyecatching style. Easily clipped to a key chain or worn as a pendant, the sleek look of this mini bullet vibrator will ensure only you know the true purpose! The Kinki Stix Finger Ring Massager even comes with a battery to start the fun right away!
Sweet and discreet, this one speed mini bullet vibe features a built-in finger ring for pinpointing pleasure, a waterproof body for aquatic enjoyment, and a shiny metallic finish for eyecatching style. Easily clipped to a key chain or worn as a pendant, the sleek look of this mini bullet vibrator will ensure only you know the true purpose! The Kinki Stix Finger Ring Massager even comes with a battery to start the fun right away!
Sweet and discreet, this one speed mini bullet vibe features a built-in finger ring for pinpointing pleasure, a waterproof body for aquatic enjoyment, and a shiny metallic finish for eyecatching style. Easily clipped to a key chain or worn as a pendant, the sleek look of this mini bullet vibrator will ensure only you know the true purpose! The Kinki Stix Finger Ring Massager even comes with a battery to start the fun right away!
Sweet and discreet, this one speed mini bullet vibe features a built-in finger ring for pinpointing pleasure, a waterproof body for aquatic enjoyment, and a shiny metallic finish for eyecatching style. Easily clipped to a key chain or worn as a pendant, the sleek look of this mini bullet vibrator will ensure only you know the true purpose! The Kinki Stix Finger Ring Massager even comes with a battery to start the fun right away!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Stu |
last post by:
Hi All,
I have an ASP.NET application to which I have implemented forms
authentication to handle security. It is a relatively straight forward
solution with all aspx pages residing in the root...
|
by: Kenneth Keeley |
last post by:
Hi,
I have a web app that has forms authentication and I can login to the
page the first time I go there but it never times me out if I come back in
24 hours a hit the refresh key the page loads...
|
by: Tom Nowak |
last post by:
I have written a web app that includes a login page. When a user
successfully logs in, they are taken to the main web app page. I have a
button on this page that I want to use to redirect the...
|
by: GreggTB |
last post by:
I've got an page (LOGIN.ASPX) that receives the user's login
information. During the page load, it checks the credentials against a
database and, if validation is successful, creates an instance of...
|
by: Michael Groeger |
last post by:
Hi,
I have implemented a simple page for FormsAuthentication and when user data
is accepted I redirect the user using
FormsAuthentication.RedirectFromLoginPage().
private void...
|
by: Anders Jacobsen |
last post by:
Hey
Im devloping an application in asp.net 1.1 SP2. I need to control timeout
values for each user. Im having trouble to make it work. When the session
timouts out I want to redirect the user to...
|
by: jobs |
last post by:
Hello.
If my users are logged in, and try to access restricted pages I want
to direct them to a custom 403 page. If they are not logged in, I
would like to continue to direct them to the login...
|
by: pveena |
last post by:
Hi,
I am new to php. I have two pages.one is login page other is details page.
When user enter detaisl page directly in URL i want to redirect to login page then login success it should go to...
|
by: pentahari |
last post by:
Redirect to login page if session("UserName") is expired when the page useraccount.aspx load event
My useraccount.aspx code :
If Session("UserName") Is Nothing Then
...
|
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= |
last post by:
I have a asp.net app. When session is invalid, how to redirect user to the
login page? I don't want to add the code to redirect user to the login page
into every page.
Thanks,
-Billy
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |