I was working on a script before taking ill. I need urgent help with this.

I have login form, and I can use http://phpeasystep.com login tutorial to do a single user login. But I need it for like 4 different users redirecting to diffrent pages after login/

The form code:

<form action="checklogin.php" method="POST" name="logForm">
  <fieldset>
  <legend>Please Login Here!</legend>
    <label for="name">Username:</label>
    <input type="text" name="username" id="username" />
    <br /> <br /> <br />
    <label for="password">Password:</label>
    <input type="password" name="password" id="password" />
    <br /> <br /> <br />
    <label for="address">User Type:</label>
    <select name="subtype" id="subtype">
        <option value="" selected="selected">Select Type..</option>
        <option value="1">User1</option>
        <option value="Nurse">User2</option>
        <option value="Accountant">User3</option>
        <option value="Lab Tech">User4</option>
    </select>
    <br /> <br /> <br />
    <label for="submit">&nbsp;</label>
    <input type="image" name="submit" src="images/login_button.png" />
  </fieldset>
</form>

I have a database with, username, password and subtype

Recommended Answers

I believe that we've advised you before about the wisdom of providing a dropdown in the login form. The form should redirect automatically on successful login since the DB stores the subtype so you can retrieve it and send them to the right page. SHould be simple.

Jump to Post

All 2 Replies

Ehh? I'm guessing you know the names of these users?

I would use sessions:

<?php

      // if sucsessfully signed in
      $_SESSION['username'] = $username;

      switch($_SESSION['username'])
      {
         case 'bob':
         // redirect for bob
         break;

         case 'harry':
         // redirect for harry
         break;

         default:
          // default redirect
      }
  ?>
Member Avatar

I believe that we've advised you before about the wisdom of providing a dropdown in the login form. The form should redirect automatically on successful login since the DB stores the subtype so you can retrieve it and send them to the right page. SHould be simple.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.