Hello friends,
can u please explain the code Login page using sessions
Rakesh Nagekar
What is done in login page is:
You just compare your typed name and password with database name and password,
if they are correct ,then you just put them in sessions like:
session_unregister(user_name);
session_register(user_name);
$_SESSION['user_name'];
Then you can use them where ever you want...
please reffer some session materials by googling...
why do you use session_register(). i thought it was depreciated.
just set your user id into a session.
here is some sample code
if (isset($_POST['submit'])) {
$user = mysql_real_escape_string($_POST['user']);
$pass = mysql_real_escape_string($_POST['pass']);
$sql = "SELECT * FROM `tablename` WHERE `username` = '{$user}' AND `password` = '{$pass}'";
$query = mysql_query($sql);
$total = mysql_num_rows($query);
if ($total > 0) {
$res = mysql_fetch_assoc($query);
$_SESSION['member'] = $res['id'];
header('Location: the/members/page.php');
}
else {
echo 'User name and/or password incorrect';
}
}
Than u keith, for giving the valuable information
can u please tell me abt the blogs in PHP and how to program
Thank u
Rakesh Nagekar
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.