Knew I forgot to mention something. No, register_globals are off. Using
$_SESSION[] variables. I am logging in first. I log in fine, its when I
try to go to another page via a link on the entry page that I get booted
back to the login page. My scripts work fine on a Unix server, which is
what I reluctantly had to go back to using as this projects deadline is
too close not to do so. Its just on my computer locally that this does
not work. Code is below, it is fairly long.
 
Example Code:
 
//validation.php
include_once 'db.php';
include_once 'common.php'
 
 session_start();
 
 $uname = isset($_POST['username']) ? $_POST['username'] :
$_SESSION['username']; 
 $pwd = isset($_POST['password']) ? $_POST['password'] :
$_SESSION['password'];
 
 if(!isset($uname))
 {
  header("Location: login.php");
  exit;
 }
 
 $_SESSION['username'] = $uname; 
 $_SESSION['password'] = $pwd;
 
 dbConnect("db"); 
 $sql = "SELECT * FROM admin WHERE 
     admin_uname = '$uname' AND admin_pword = PASSWORD('$pwd')";
 $result = mysql_query($sql); 
 
 if (!$result) { 
  error('A database error occurred while checking your login
details.\\nIf this error persists, please contact
[EMAIL PROTECTED]'); 
 }
 
 while($row = mysql_fetch_array($result))
 {
  $admin_id = $row['admin_id'];
 }
 
 $_SESSION['aid'] = $admin_id;
 
 if (mysql_num_rows($result) == 0) { 
   unset($_SESSION['username']); 
   unset($_SESSION['password']);
   
   header("Location:login.php?item=badlogin");
   exit;  
 }
 
_______________________________________________________
//login.php
... this is an html page with the login form. When submitted it goes to
index.php.
 
_______________________________________________________
//index.php
include('validation.php');
 
 if(!$_SESSION['aid'])
 {
  header("Location:login.php");
  exit;
 }
.... rest of page is HTML with a php include for the navigation....
_______________________________________________________
//nav.php
<.a href="admin_signup.php">Add Admin</a>
 
_______________________________________________________
//admin_signup.php
include('validation.php');
 
 if(!$_SESSION['aid'])
 {
  header("Location:admin_login.php");
  exit;
 }
.... rest of page is HTML with a form that goes to add_admin.php for
validation and submission to the database. Its when I try to go to this
page via the link that I get sent back to the login page.
 

Jami Moore
LightSpark Digital Designs
 <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED]
 <http://www.lightsparkdigital.com/> http://www.lightsparkdigital.com/

 


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]

Sent: Wednesday, September 17, 2003 3:08 AM


Did you open register_globals = On in php.ini? 


 -----Original Message----- 
Larry Li/CNTR/APPLIED [EMAIL PROTECTED] 
09/17/2003 04:04 PM   

I believe all pages in your site are protected by session variables. Try

to login first, then go where you want to go. Or try to remark codes
which 
check your login status. 


-----Original Message-----
"Jami" <[EMAIL PROTECTED]>
09/17/2003 03:52 PM

I'm working on a project, and up until recently was using my hosting
account to do projects, but decided to update PHP on my comp to be able
to work on projects locally. I'm running WindowsXP, PHP 4.3.2, Apache
1.3, and MySQL 3.23.53. The validation page is called on each page, but
if I go to a page other than the entry page (which the validation page
takes you to when you first log in), it throws me back to the login
page. Has anyone run into this and have you solved it? Anyone have a
suggestion? Code is rather lengthy, if you want it I can send it off
list.

Jami Moore
LightSpark Digital Designs
<mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED]
<http://www.lightsparkdigital.com/> http://www.lightsparkdigital.com/






Reply via email to