[PHP-DB] RE: Session help...

2003-07-30 Thread NIPP, SCOTT V (SBCSI)
Thanks for the responses.  I ended up resolving this by fixing the
form destination.  I had hard coded a location in there, and did not realize
this.  Once I replaced this with the PHP variable everything magically
started to work.  My bad on that.  Thanks again for the feedback though.

-Original Message-
From: Ow Mun Heng [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 29, 2003 11:13 PM
To: NIPP, SCOTT V (SBCSI); [EMAIL PROTECTED]
Subject: RE: Session help...


As mentioned previously in this list,

$_SESSION and session_register, session_is_register, is not compatible with
each other.

Anyway, I used your idea as inspiration for my own code.. My code works.. 

Try to change From:
if (!session_is_registered(valid_user)) {

To:
if ($_SESSION['valid_user']){
//your code
}

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: NIPP, SCOTT V (SBCSI) [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 29, 2003 9:19 PM
To: [EMAIL PROTECTED]
Subject: Session help...


Sorry for the slightly off-topic post...  I have a couple pages that
use a login page.  If the user tries to bring up one of these pages without
being logged in, then the pages redirects him to the login page.  After
successful login, the user is directed back to the page they were attempting
to originally load.  For some reason, this is not working and I have been
looking at this off and on for two days now without much luck.  The first
section of code is the snippet that directs users to the login page, and the
second snippet is the code from the login page that sends users back.

First code snippet...

session_start();
if ($sbcuid  $passwd) {
  mysql_select_db($database, $Prod);
  $query = select * from contacts_sa 
   . where sbcuid='$sbcuid' and passwd='$passwd';
  $result = mysql_query($query, $Prod) or die(mysql_error());
  # $data = mysql_fetch_assoc($result);
  $test = mysql_num_rows($result);
  if (mysql_num_rows($result) 0 )
  {
$valid_user = $sbcuid;
$_SESSION['valid_user'] = $sbcuid;
  }
}

if (!session_is_registered(valid_user)) {
  $return_url = $_SERVER['PHP_SELF'];
  $_SESSION['return_url'] = $return_url;
  header('Location: http://ldsa.sbcld.sbc.com/DW/sa_login.php');
  exit();
} else {
  $sbcuid = $valid_user;
}

End of first snippet...

Second code snippet...

session_start();
if ($sbcuid  $passwd) {
  if (isset($_SESSION['return_url'])) {
$link = $_SESSION['return_url'];
} else {
  $link = 'oncall_log.php';
  }
  mysql_select_db($database, $Prod);
  $query = select * from contacts_sa 
   . where sbcuid='$sbcuid' and passwd='$passwd';
  $result = mysql_query($query, $Prod) or die(mysql_error());
  # $data = mysql_fetch_assoc($result);
  $test = mysql_num_rows($result);
  if (mysql_num_rows($result) 0 ) {
$valid_user = $sbcuid;
# session_register(valid_user);
$_SESSION['valid_user'] = $sbcuid;
header(Location: http://.$_SERVER['HTTP_HOST'].$link);
  }
}

End of second snippet...

Thanks in advance for any help.
Scott Nipp
Phone:  (214) 858-1289
E-mail:  [EMAIL PROTECTED]
Web:  http:\\ldsa.sbcld.sbc.com


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] RE: Session help...

2003-07-29 Thread Ow Mun Heng
As mentioned previously in this list,

$_SESSION and session_register, session_is_register, is not compatible with
each other.

Anyway, I used your idea as inspiration for my own code.. My code works.. 

Try to change From:
if (!session_is_registered(valid_user)) {

To:
if ($_SESSION['valid_user']){
//your code
}

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: NIPP, SCOTT V (SBCSI) [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 29, 2003 9:19 PM
To: [EMAIL PROTECTED]
Subject: Session help...


Sorry for the slightly off-topic post...  I have a couple pages that
use a login page.  If the user tries to bring up one of these pages without
being logged in, then the pages redirects him to the login page.  After
successful login, the user is directed back to the page they were attempting
to originally load.  For some reason, this is not working and I have been
looking at this off and on for two days now without much luck.  The first
section of code is the snippet that directs users to the login page, and the
second snippet is the code from the login page that sends users back.

First code snippet...

session_start();
if ($sbcuid  $passwd) {
  mysql_select_db($database, $Prod);
  $query = select * from contacts_sa 
   . where sbcuid='$sbcuid' and passwd='$passwd';
  $result = mysql_query($query, $Prod) or die(mysql_error());
  # $data = mysql_fetch_assoc($result);
  $test = mysql_num_rows($result);
  if (mysql_num_rows($result) 0 )
  {
$valid_user = $sbcuid;
$_SESSION['valid_user'] = $sbcuid;
  }
}

if (!session_is_registered(valid_user)) {
  $return_url = $_SERVER['PHP_SELF'];
  $_SESSION['return_url'] = $return_url;
  header('Location: http://ldsa.sbcld.sbc.com/DW/sa_login.php');
  exit();
} else {
  $sbcuid = $valid_user;
}

End of first snippet...

Second code snippet...

session_start();
if ($sbcuid  $passwd) {
  if (isset($_SESSION['return_url'])) {
$link = $_SESSION['return_url'];
} else {
  $link = 'oncall_log.php';
  }
  mysql_select_db($database, $Prod);
  $query = select * from contacts_sa 
   . where sbcuid='$sbcuid' and passwd='$passwd';
  $result = mysql_query($query, $Prod) or die(mysql_error());
  # $data = mysql_fetch_assoc($result);
  $test = mysql_num_rows($result);
  if (mysql_num_rows($result) 0 ) {
$valid_user = $sbcuid;
# session_register(valid_user);
$_SESSION['valid_user'] = $sbcuid;
header(Location: http://.$_SERVER['HTTP_HOST'].$link);
  }
}

End of second snippet...

Thanks in advance for any help.
Scott Nipp
Phone:  (214) 858-1289
E-mail:  [EMAIL PROTECTED]
Web:  http:\\ldsa.sbcld.sbc.com



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php