Jump to content

[PHP,HTML] login page detect more than 1 table


r1nk

Recommended Posts

Hello, im a new user here. Im now working on a project called student attendance management sytem. I have doing all the necessary tables in database which is  admin, lecturer, student, parent, attendance and grade. Ok so im now working on a 1st page which is a login page.
 
Right now i have finished the coding and what im gonna ask u all is how to make sure that when i clicked 'login', it not only detect the admin table but all of other tables?

<html>
	<head>
		<title> Login Form </title>
	</head>

<body>
<form method='post' action='login.php'>
	<table width='400' border='5' align='center'>
	<tr>
		<td align='center'
		colspan='5'><h1>Login Form</h1></td>
	</tr>
	
	<tr>
		<td align='center'>Username:</td>
		<td><input type='text' name='username' /></td>
	</tr>
	
	<tr>
		<td align='center'>Password:</td>
		<td><input type='password' name='pass' /></td>
	</tr>
	
	<tr>
		<td colspan='5' align='center'><input type='submit' name='login' value='Log In' /></td>
	</tr>
	
	</table>
</form>
</body>
</html>
<?php
mysql_connect("localhost","root","");
mysql_select_db("student_attendance");

if(isset($_POST['login'])){

	$username = $_POST['username'];
	$password = $_POST['pass'];
	
	$check_user = "select * from admin where username='$username' AND pass='$password'";
	
	$run = mysql_query($check_user);
	
	if(mysql_num_rows($run)>0){
	
	echo
	"<script>alert('You are logged in')</script>";
	}
	else {
	echo "<script>alert('username or password is incorrect!')</script>";
	}
}

?>
Link to comment
Share on other sites

ok, just to make sure no problem will arise later bcoz of the tables. So, right now these are my initial tables.

 

http://i272.photobucket.com/albums/jj178/r1nk_2008/1_zpsf1765f1c.png

http://i272.photobucket.com/albums/jj178/r1nk_2008/2_zpsa1a1310a.png

http://i272.photobucket.com/albums/jj178/r1nk_2008/3_zps092b7ff1.png

http://i272.photobucket.com/albums/jj178/r1nk_2008/4_zps1fffbc49.png

 

If i delete those 4 users table and create a new one called users ( id, name, username, password, type_of_user), then wouldn't it be a problem later when : -

 

- the admin wanna asign course_id for the added lecturer

- the lecturer enter his/her course_id and the whole students in that course can be viewed

Link to comment
Share on other sites

you also don't need a user type dropdown on your login page, since you will know which type the user is when you authenticate them against this single user table that contains the type_of_user column.

 

the only place you would need a user type dropdown is you are allowing an administrator to assign a user type to other user(s).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.