PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
taech
Forum Newbie
Posts: 4 Joined: Mon Oct 27, 2003 4:47 pm
Post
by taech » Mon Oct 27, 2003 5:04 pm
heres my login(.php) page:
Code: Select all
<?php
session_start();
$username = $_POSTї'username'];
$password = $_POSTї'password'];
if(!$_POST)
{
include 'html/loginform.html';
}
elseif((!$username) || (!$password))
{
echo "Please enter ALL of the information! <br />";
include 'html/loginform.html';
}
else
{
$qstr = "SELECT * from members where username = '$username' and password = '$password'";
$result = mysql_query($qstr);
if (mysql_num_rows($result))
{
$result = mysql_fetch_array($result);
$banned = $resultї"banned"];
$email = $resultї"email"];
$name = $resultї"name"];
$password = $resultї"password"];
$points = $resultї"points"];
$post = $resultї"post"];
$user_level = $resultї"user_level"];
$_SESSIONї'banned'] = $banned;
$_SESSIONї'email'] = $email;
$_SESSIONї'name'] = $name;
$_SESSIONї'password'] = $password;
$_SESSIONї'points'] = $points;
$_SESSIONї'post'] = $post;
$_SESSIONї'user_level'] = $user_level;
$_SESSIONї'username'] = $username;
echo "<br><font color=#008000><Center><b>**Successful Login**</b></Center></font>";
}
else
{
echo "<br><font color=#ff0000><Center><b>**Failed Login**</b></Center></font>";
}
}
?>
and as stated in the title, when I login it wil login all right, but then when i got to the next page, it forgets that i have logged on
...
so, any help?
-thx
m3rajk
DevNet Resident
Posts: 1191 Joined: Mon Jun 02, 2003 3:37 pm
Post
by m3rajk » Mon Oct 27, 2003 5:06 pm
becuase post isn't set on all pages. it can be on form pages, but not on all. do you check for the session variable to see if someone's logged in anywhere?
d3ad1ysp0rk
Forum Donator
Posts: 1661 Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA
Post
by d3ad1ysp0rk » Mon Oct 27, 2003 5:29 pm
do you have session_start(); on all pages?
and do you declare
$username = $_SESSION['username'];
and
$password = $_SESSION['password'];
on each page?
taech
Forum Newbie
Posts: 4 Joined: Mon Oct 27, 2003 4:47 pm
Post
by taech » Mon Oct 27, 2003 5:58 pm
m3rajk i do know that post isnt set on all pages also i do check the sessions but only where i need it.
yes i do LiLpunkSkateR
JAM
DevNet Resident
Posts: 2101 Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:
Post
by JAM » Mon Oct 27, 2003 6:04 pm
What do you see if you;
Code: Select all
// change...
echo "<br><font color=#008000><Center><b>**Successful Login**</b></Center></font>";
// ...to...
echo "<br><font color=#008000><Center><b>**Successful Login**</b></Center></font>";
echo '<pre>';
print_r($_SESSION);
echo '</pre>';
taech
Forum Newbie
Posts: 4 Joined: Mon Oct 27, 2003 4:47 pm
Post
by taech » Mon Oct 27, 2003 6:32 pm
**Successful Login**
Array
(
[banned] => 0
[email] =>
email@email.com
[name] => myname
[password] => mypass
[points] => 10
[post] => 0
[user_level] => 3
[username] => admin
)
JAM
DevNet Resident
Posts: 2101 Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:
Post
by JAM » Mon Oct 27, 2003 6:48 pm
Bah, I was hoping that I could narrow it down abit, but no. As that works the session is indeed set. Other thing i thought of was missing to use session_start() on the next page, but you allready stated that you did...
Sorry, but I'm stumped...
zenabi
Forum Commoner
Posts: 84 Joined: Mon Sep 08, 2003 5:26 am
Location: UK
Post
by zenabi » Tue Oct 28, 2003 6:54 am
Not sure if this will help, but I found this from php.net:
If you have problems with getting "session_start()" working on a Windows XP machine try this:
Change "session.save_path" in the "php.ini" file from "session.save_path = /tmp" to "C:\WINDOWS\Temp".