Stuck on you!

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

Post Reply
User avatar
crypdude
Forum Newbie
Posts: 18
Joined: Sun May 23, 2004 10:26 pm

Stuck on you!

Post by crypdude »

Code: Select all

<?php
<?
if(@$HTTP_GET_VARSї'logout']==1) { //log out user
session_start();
$HTTP_SESSION_VARS = array();
session_destroy();
}
if(isset($HTTP_POST_VARSї'submit']) ) {     // true if form has been submitted

   require("access.inc.php");
   mysql_connect("$host","$login","$pass") OR DIE
      ("There is a problem with the system.  Please notify your system administrator." .mysql_error());
   mysql_select_db("$db") OR DIE
      ("There is a problem with the system.  Please notify your system administrator." .mysql_error());
 
$mdpass=MD5($HTTP_POST_VARSї'pass1']);
   $query = "SELECT ID,level FROM ".$confї'tbl']ї'teachers']." where pass='$mdpass' AND user="$HTTP_POST_VARSїusername]"";

   $result = mysql_query($query);
   $query_data = mysql_fetch_row($result);

      IF (!$query_dataї0]) { 
      $error = "You have submited an incorrect login and password combination.  Please try again.";
      }

   ELSE {

      session_start();

      $HTTP_SESSION_VARSї'secure_id']=$query_dataї0];            
      $HTTP_SESSION_VARSї'secure_level']=$query_dataї1];  
	  echo ("Query data 0 = $query_dataї0]");
	  echo ("Query data 1 = $query_dataї1]");

      IF($HTTP_SESSION_VARSї'secure_level']==1) {
         header("location: admin/admin.php");
      }
      IF($HTTP_SESSION_VARSї'secure_level']==2) {
         $error = "Your account has been de-activated.  Please contact the system administrator for details.";
      }
        IF($HTTP_SESSION_VARSї'secure_level']==6) {
         $error = "Your account has been de-activated.  Please contact the system administrator for details.";
      }
      IF($HTTP_SESSION_VARSї'secure_level']==0 || $HTTP_SESSION_VARSї'secure_level']==5) {
         $error = "Your account has yet to be activated.  Please contact the system administrator for details.";  
      }
       IF($HTTP_SESSION_VARSї'secure_level']==4) {
        header("location: teacher/announceadmin.php");  
      }
      IF ($HTTP_SESSION_VARSї'secure_level']==3) {   
        //header("location: teacher/teacheradmin.php");
      }
   }

}
?>

<HTML><HEAD><TITLE>Login Page</TITLE>
<LINK REL ="stylesheet" HREF="style.css" TYPE="text/css">
<?
include("header1.php");
echo '<span class=title>Login</span><P>';

IF (isset($HTTP_GET_VARSї'error'])) { echo "<P><B>$HTTP_GET_VARSїerror]</B>"; }

IF (isset($error)) { echo "<P><B>$error</B>"; }

//ELSE { echo "<P><B>$error</B>"; }

echo "<FORM METHOD=POST ACTION=login.php>";

?>
<P><TABLE><TR><TD>
User Name:</TD><TD><INPUT TYPE=TEXT NAME=username WIDTH=20></TD></TR>
<TR><TD>Password:</TD><TD>
<INPUT TYPE=password NAME=pass1 WIDTH=20></TD></TR>
<TR><TD COLSPAN=2>
<INPUT TYPE=SUBMIT VALUE=Login NAME=submit>
<BR><A HREF=forgot.php?Submit2=1&email=>Forgot your password</A>?
<BR><A HREF=register.php>Need to register</A>?
</TD></TR></TABLE>
</FORM>
<?
include("footer.php");
?>
?>
I got this code from internet, then the main concern is on code

Code: Select all

<?php
      session_start();

      $HTTP_SESSION_VARS['secure_id']=$query_data[0];            
      $HTTP_SESSION_VARS['secure_level']=$query_data[1];  
	  echo ("Query data 0 = $query_data[0]");
	  echo ("Query data 1 = $query_data[1]");

      IF($HTTP_SESSION_VARS['secure_level']==1) {
         header("location: admin/admin.php");
      }
      IF($HTTP_SESSION_VARS['secure_level']==2) {
         $error = "Your account has been de-activated.  Please contact the system administrator for details.";
      }
        IF($HTTP_SESSION_VARS['secure_level']==6) {
         $error = "Your account has been de-activated.  Please contact the system administrator for details.";
      }
      IF($HTTP_SESSION_VARS['secure_level']==0 || $HTTP_SESSION_VARS['secure_level']==5) {
         $error = "Your account has yet to be activated.  Please contact the system administrator for details.";  
      }
       IF($HTTP_SESSION_VARS['secure_level']==4) {
        header("location: teacher/announceadmin.php");  
      }
      IF ($HTTP_SESSION_VARS['secure_level']==3) {   
        //header("location: teacher/teacheradmin.php");
      }
   }

?>
I dont know how the secure_level coming in.. I'm stuck here... what the session_start() method really are? and then how about this stuff($HTTP_SESSION_VARS['secure_level']=="x") ? I try to find by myself then cant. Hope some favor!
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

You can find out all those questions and more right here: http://www.php.net/docs.php

In many different languages, too!

If after reading the documentation, you still don't understand, come back here and explain to us what you didn't understand about the documentation, and where it was confusing, and we will help you along.
User avatar
crypdude
Forum Newbie
Posts: 18
Joined: Sun May 23, 2004 10:26 pm

Post by crypdude »

Thanks Jason, U are so cute and smart!
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

crypdude wrote:Thanks Jason, U are so cute and smart!
No-one ever said that to me on this board. :cry: :cry:
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

crypdude wrote:Thanks Jason, U are so cute and smart!
LOL :lol:

Jason you little cutie :oops:
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

:lol:
Post Reply