Session help...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



	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:  sn4265@sbc.com
Web:  http:\\ldsa.sbcld.sbc.com



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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux