0

Hello every1,
i'm building a site that requires logging in before accessing other pages(like facebook or any mail system).
At first(in index) i create an object of my sessions class, say $session. The constructor of sessions class calls session_start() php function.
$session checks if user logged in or not(maybe he was remembered in cookies) and if not, $session directs him to login page. So, how can I use $session object(which is constructed in index page)in login page???

Thnx

Edited by Acute: n/a

4
Contributors
11
Replies
14
Views
6 Years
Discussion Span
Last Post by diafol
Featured Replies
0

sessions allow you to pass objects in addition to variables. Just include the class in all the relevant pages. If you have methods in your class, they need to be available for the object.

*Need more info*

0

Yes, but $session object itself object that handles sessions, how can i pass it through session?

Edited by Acute: n/a

0

i have some issue on logincheck page....
when i use md5 for my password its not working...
its always go to login failed page
pls help me ....


code
-------


<?php
session_start();
$host="192.168.200.100";
$username="emt_dev";
$password="ready2go#";
$db_name="emtd101";
$tbl_name="M_USER";


mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");


$myusername=$_POST;
$mypassword=$_POST;


$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$encrypted_mypassword=$mypassword;

$sql="SELECT * FROM $tbl_name WHERE MUSE_NAME='$myusername' and MUSE_PWD='$encrypted_mypassword'";
$result=mysql_query($sql);

$count=mysql_num_rows($result);


if($count==1)
{

session_register("txtusername");
session_register("txtpassword");
header("location:Main_Dashboard.php");
}
else

header("location:loginfailed.php")

?>

0

When you register a new user, you save the password in db with md5($password), right?
Here I don't see where you use md5() before comparing two passwords...

maybe

$encrypted_mypassword=md5($mypassword);

Edited by Acute: n/a

0

i save a new user in db with md5 password.
here i use the md5() just before the query


$encrypted_mypassword=$mypassword;// this is md5 which i use to encrypt

$sql="SELECT * FROM $tbl_name WHERE MUSE_NAME='$myusername' and MUSE_PWD='$encrypted_mypassword'";
$result=mysql_query($sql);

$count=mysql_num_rows($result);

0

his was the code


<?php
session_start();
$host="192.168.200.100";
$username="emt_dev";
$password="ready2go#";
$db_name="emtd101";
$tbl_name="M_USER";


mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");


$myusername=$_POST;
$mypassword=$_POST;


$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$encrypted_mypassword=md5($mypassword);

$sql="SELECT * FROM $tbl_name WHERE MUSE_NAME='$myusername' and MUSE_PWD='$encrypted_mypassword'";
$result=mysql_query($sql);

$count=mysql_num_rows($result);


if($count==1)
{

session_register("txtusername");
session_register("txtpassword");
header("location:Main_Dashboard.php");
}
else

header("location:loginfailed.php")

?>

0

hello every1,
i'm building a site that requires logging in before accessing other pages(like facebook or any mail system).
At first(in index) i create an object of my sessions class, say $session. The constructor of sessions class calls session_start() php function.
$session checks if user logged in or not(maybe he was remembered in cookies) and if not, $session directs him to login page. So, how can i use $session object(which is constructed in index page)in login page???

Thnx

checkout my if statment thread soloved then send me a message for mor files like logout member pages

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.