r1nk Posted August 27, 2013 Share Posted August 27, 2013 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>"; } } ?> Quote Link to comment Share on other sites More sharing options...
requinix Posted August 27, 2013 Share Posted August 27, 2013 Don't use four tables if one will do. Then add a column to it indicating what type of user is in each row. Quote Link to comment Share on other sites More sharing options...
r1nk Posted August 27, 2013 Author Share Posted August 27, 2013 owhh so i need to add one more new table with a column of user type.. ok thanks.. now im searching for the coding to add a dropdown user type option in login page.. gonna ask u if i cant find..hehe Quote Link to comment Share on other sites More sharing options...
requinix Posted August 27, 2013 Share Posted August 27, 2013 You're not adding yet another table. You're creating a new table for all the users and getting rid of the four you have now. Quote Link to comment Share on other sites More sharing options...
r1nk Posted August 28, 2013 Author Share Posted August 28, 2013 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 Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted August 28, 2013 Share Posted August 28, 2013 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). Quote Link to comment Share on other sites More sharing options...
r1nk Posted August 28, 2013 Author Share Posted August 28, 2013 yupp.. that's what im planning.. only the admin can register for other type of user including register the course id.. but of course other users can change their password after they logged in. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.