Jump to content

adiwood

Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

adiwood's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, Thank you for your reply. I have edited the code, and it still works, so that is sorted. Will looking into the sessions now. Thank you for your reply.
  2. Hi, I have been trying to look at some of the session tutorials, although i always seem to get lost, since i dont know how to apply them to what i have. I have a login page, that the user fills in the username and password, a response page then validates the user, and redirects them to the correct page depending on their usertype - e.g username, admin, superadmin. Where do i have to put the different parts of the session so that users can access to the admin page by typing it in. Also, this code is rather long winded at the moment. How can i cut it down? I guess i need to do something with $blnHitError = true; Sorry, but im totally lost on this!! Below is my code: [code]<?php          {     $domain = "localhost";     $username = "root";     $password = "paxcroft";     $database = "traceability";     $connection = mysql_connect($domain, $username, $password);     $database = mysql_select_db($database, $connection);     $user = mysql_query("SELECT `Userid`,`UserType` ".                             "FROM `Users` ".                             "WHERE `UserName` = '".$_POST['username']."' ".                             "AND `Password` = '".$_POST['password']."' ".                             ";", $connection);     $userRecord = mysql_fetch_array($user);     $UserType = $userRecord["UserType"];     if ($userRecord["Userid"] > 0) {         $CurrentUser = $userRecord["Userid"];         if (!$_POST['password'] = $userRecord["password"]) {             if ($UserType == 'User') {             session_register("$username","$password");             header( "Location: user.php" );             } elseif ($UserType == 'Admin') {                 session_register("$username","$password");              header( "Location: admin.php" );             } elseif ($UserType == 'SuperAdmin') {                 session_register("$username","$password");              header( "Location: superadmin.php" );             };         };     } else {         ?>         <html>         <head>         <title>Avon Technical Products Traceability System</title>         <link rel=StyleSheet href="style.css" type="text/css">         </head>         <body>         <form action="response.php" method="POST">         <div id="wrapper">             <div id = "header">                 <div id = "logo">                     <img src="images/avon_logo.gif" alt="Avon Technical Products" title="Company logo" />                 </div>                 <div id = "pageInfo">Avon Technical Products Traceability System</div>             </div>             <div id="subNav">                 <li><A HREF="index.php"><div id="button">Try Again</div></a></li>             </div>             <div id = "content">                 <div id = "mainContent">                     <div id = "title">LogOn</div>             <div id = "Information">               Sorry, unable to login. Please check your user name and password.               </div>                         </div>                     </div>                 </div>             </div>             </form>             </body>         </html>         <?php     }     mysql_close($connection); } ?>[/code]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.