session problem?
Posted: Wed Sep 28, 2011 4:05 am
hi im new to this forums and im not quite good at php so i have some question it would be great if someone could help me..(and yeah i hate spoonfeeding since its bad and it would not help people so if you could point me to some site or even lectures i would be more than gratefull *:)*)
i'll numerate some questions.. hehe:
1.) i've been creating a small work in my class and i made the structure like homepage>logintest(check wether admin or no)>throw to the according user level. but im having problems with my sessions...(im quite confused in sessions.. )
but here's my code :
in my homepage part
in my logintest part
then the prblem part.. i think
view profile page.
im very sorry if this is too long... but i would greatly appreciate any help i could get
i'll numerate some questions.. hehe:
1.) i've been creating a small work in my class and i made the structure like homepage>logintest(check wether admin or no)>throw to the according user level. but im having problems with my sessions...(im quite confused in sessions.. )
but here's my code :
in my homepage part
<FORM action='logintest1.php' method='POST'>this is correct right? i think this is the only impt. part in the 1st page
in my logintest part
<?php
session_start();
ini_set('display_errors', 1 );
error_reporting(E_ALL & ~ E_NOTICE);
$username = $_POST['username'];
$password = $_POST['password'];
if ($username&&$password)
{
$connect = mysql_connect("localhost","root","") or die("could not connect");
mysql_select_db("3vfarmthesis") or die ("could not find db");
$query = mysql_query("SELECT * FROM users WHERE username ='$username'");
$numrows = mysql_num_rows($query);
if($numrows!=0)
{
while($row = mysql_fetch_assoc($query))
{
$dbusername = $row['username'];
$dbpassword = $row['password'];
$activated = $row['activated'];
$admin = $row['admin'];
if ($activated == '0' )
{
echo "you're account is not yet active check your email";
//exit();
}
}
//to see if they match
if ($username == $dbusername && md5($password) == $dbpassword )//hash
{
if($admin == '0')
{
header('location:revisedglen/ClientView/viewprofile.php'); //client
}
else
{
header('location:revisedglen/AdminView/index.php'); //admin
}
}
else
//wrong password
header('location:HomeCent.php');
firstE();
}
else
{
die ("that user does not exist");
}
}
else
{
die("please enter a username and a password ");
}
?>
$username = $_POST['username']; it came from the earlier page .then the prblem part.. i think
view profile page.
<?php
$con = mysql_connect("localhost","root","");
mysql_select_db("3vfarmthesis", $con);
$username = $_POST['username'];
$sql = mysql_query("SELECT * FROM login,clientprofile WHERE Email = '$username' ");
?>
i'm having trouble in the sql statement how can i call any information that i used in the homepage part.(for example the username in my homepage) so that i could view the profile of the client.. this is all about session right? im very sorry if this is too long... but i would greatly appreciate any help i could get