GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 22-May-2004, 03:13
eRIC eRIC is offline
Awaiting Email Confirmation
 
Join Date: Nov 2003
Location: Kyrgyzstan
Posts: 31
eRIC is on a distinguished road
Red face

Session Problem


In index.php there is form for enterence user and password.
index.php
****************
PHP Code:

<?
session_unset();
session_destroy();
session_start();
session_register(uniqid(rand()));
if ($error)
{ //$ucolor="red"; $upasswd="red";
echo "<center>";
echo "<font race=\"verdana\" size=\"5\" color=\"red\"><b>{ Access Denied }</b><br></center><P>";
}
else if ($error=="logout")
{
echo "<center>";
echo "<font race=\"verdana\" size=\"5\" color=\"red\"><b>{ Log in }</b><br></center><P>";
}
.
.
.
.
?>


*********************
secret.php
PHP Code:

(it is simple for now)
<?
session_start();
  if($Submit)
  {if(($ausername=="eric")&&($apasswd=="dfeef"))
    {$logged_user = $ausername;
      session_register("logged_user");
      header("Location: list.php");
      exit;
    }
    else if(($ausername=="admin")&&($apasswd=="pooolk"))
    {
      $logged_user = $user_name;
      session_register("logged_user");
      header("Location: adminpanel.php");
      exit;
    }
  else
   {header("Location: index.php?error=$logid&user=$ausername");
    exit;
   }
}
?> 



adminpanel.php
PHP Code:

<?
  unset($logged_user);
  session_start();
  session_register($logged_user);
  if(!isset($logged_user))
  { $err=1;
    header("Location:index.php?error=$err");
    exit();
  }
....
.
?>


Problem is here in header. When i use header("Location:adminpanel.php"); it says error. does header send sessions too? or not? if does how i must send.
and i wanto destroy all sessions opened by my site how can i do?
What can i do here?

I have
logout.php
PHP Code:

<?
session_start();
session_unset();
session_destroy();
if (session_destroy())
{$err="logout";
header("Location:index.php?error=$err");
exit();}
?>



THANKS !!!!!!!!!!!!!!!!!!!!!!!!!
Last edited by JdS : 22-May-2004 at 23:24. Reason: Please enclose PHP code in [php] & [/php] for syntax highlighting
  #2  
Old 22-May-2004, 23:40
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
eRIC,

When you post php code examples, please enclose the code with [php] bbcode tags instead of [COLOR].

About your issue, once a user has logged in and you want to re-direct them to a 'secret' page via the login script, you MUST include the session ID information in the header() location, in the query string.

e.g. die( header('location:/example_secret_page_1.php?'.SID) );.

Please look at this example login code here: http://www.gidforums.com/t-887.html
 
 

Recent GIDBlogProblems with the Navy (Chiefs) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
session error bananatji MySQL / PHP Forum 2 17-May-2004 23:37
C I/O problem kelly80 C Programming Language 4 27-Apr-2004 21:15
Another FX 5600 problem (but with details that might shed light on this) BobDaDuck Computer Hardware Forum 2 16-Apr-2004 08:53
problem with php5 cgi installation fab13 Apache Web Server Forum 3 19-Nov-2003 10:11
unwanted scrollbar problem kelly001 Web Design Forum 3 24-Oct-2003 11:44

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 00:46.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.