Can any1 help!! I am creating a library management and student system, but depending on the 2 set passwords given will open up the next page.

Library managers details will be:

username: Manager
password: books10

and students will be:

username:student
password:loan

so depending on which username and password they enter, it will either open library management system or student system!

Recommended Answers

All 9 Replies

So what's the question?

If I do understand it correctly you have 1 form but depending on the input you want to go to page 2 or page 3. If so, this might be what you are looking for:

if(isset($_POST['option 1']) && isset($_POST['option 2'])){
header("Location: home.php");
}elseif(isset($_POST['option 1'])){
include("option1.php");
}elseif(isset($_POST['option 2']))(
include("option2.php");
}
header("Location: anywhere.php");

Are you using a database?

if so create a level or access field and use 0 as student 1 as manager

then call the level or access and direct them to the desired page

<?php

// check login credentials ...//
if ($level == 1){
header('Location: manager.php');}

?>

and so on....

Hope it helps...

yep have a database so do i need a table called login?? Then what the could for it getting the info from that table!! So confused!! please help!! :)

On page 1 you have a form and after clicking submit goto page 2. There you check who did login. If it is a student you include the file "student.php" to handle the student system. If it is a manager you include the file "manager.php" to handle the manager system.
What you need to change and where, is hard to tell without seeing any code from you.

<?php

// Define your username and password
$username = "username";
$password = "password";

if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) {
		//Header("HTTP/1.0 401 Unauthorized"); 
		echo "Sorry, your password does not match!!";
		//exit;
?>

<h3>Login Failed! Please try again... </h3>

<form>
<input type="button" value="Back" onClick="history.go(-1);return true;"></center>
</form

<?php

}
else {

?>
<h2> Your login  was successful! </h2>
<h3> Click on the link below to begin using the system </h3>

<form>

<input type="button" value="Enter The System" onClick="parent.location='libraryindex.html'>

</form>

?>

I am only using one set username and password at the minute which is linking to the library system! I just need it so i can set 2 usernames and password and depending on which is entered the correct page appears.....

<?php
 
// Define your username and password
$username = "username";
$username2 = "username2";
$password = "password";
$password2 = "password2";
 
if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) && ($_POST['txtUsername'] || $username2 || $_POST['txtPassword'] != $password2) {
		//Header("HTTP/1.0 401 Unauthorized"); 
		echo "Sorry, your password does not match!!";
		//exit;
?>
 
<h3>Login Failed! Please try again... </h3>
 
<form>
<input type="button" value="Back" onClick="history.go(-1);return true;"></center>
</form
 
<?php
 
}
else {
    if ($_POST['txtUsername'] = $username) 
       $targetform = "libraryindex.html"
   else
       $targetform = "adminindex.html"
?>
<h2> Your login  was successful! </h2>
<h3> Click on the link below to begin using the system </h3>
 
<form>
<input type="button" value="Enter The System" onClick="parent.location='$targetform'> 
</form>

Note that this not, however, a well designed system. You should use sessions to ensure the user is who they say they are, otherwise I could just type, "http://server name.com/libraryindex.html and get into the site.

And could i set some validation in to solve this..so that you cant just type in the address?? Thanks for the help!!

Be a part of the DaniWeb community

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