r1nk
Members-
Posts
26 -
Joined
-
Last visited
r1nk's Achievements
Newbie (1/5)
0
Reputation
-
EDIT: about no 3, the user table i show you is the old one.. i do updated the table to match my coding in the view_users.php about no 5 and no 7, yes, i would like the teacher to be assigned with his/her own courses and subjects so that when he/she want to take attendance, he/she need to click the course and subject 1st..
-
ok i updated my view_users.php and my edit.php.. view_users.php <?php session_start(); require_once('function.php'); //Set this to what ever page you include that holds all your functions so that we can use the checkUserStatus() checkUserStatus('admin'); ?> <html> <head> <title> View Users </title> </head> <body> <h2 align='right'><a href='admin.php'>Home</a></h2> <center><h2>Users Information</h2><center> <table width='800' align='center' border='5'> <tr bgcolor='yellow'> <th>No.</th> <th>Full Name</th> <th>Matrix No.</th> <th>Username</th> <th>Password</th> <th>User Type</th> <th>Edit User</th> <th>Delete User</th> </tr> <?php mysql_connect("localhost","root",""); mysql_select_db("class_attendance"); $query = "select * from user"; $run = mysql_query($query); while ($row=mysql_fetch_array($run)){ $id = $row[0]; $full_name = $row[1]; $matrix_no = $row[2]; $username = $row[3]; $pass = $row[4]; $type = $row[5]; ?> <tr align='center'> <td><?php echo $id; ?></td> <td><?php echo $full_name; ?></td> <td><?php echo $matrix_no; ?></td> <td><?php echo $username; ?></td> <td><?php echo $pass; ?></td> <td><?php echo $type; ?></td> <a href="edit.php?user_id=<?= $id ?>">Edit</a> <td><a href='delete.php?del=<?php echo $id;?>'>Delete</a></td> </tr> <?php } ?> </table> </body> </html> edit.php <?php session_start(); require_once('function.php'); //Set this to what ever page you include that holds all your functions so that we can use the checkUserStatus() checkUserStatus('admin'); ?> <html> <head> <title> Student/Lecturer Course Form </title> </head> <body> <h2 align='right'><a href='admin.php'>Home</a></h2> <?php mysql_connect("localhost","root",""); mysql_select_db("class_attendance"); $courses = $subjects = array(); $sql = "SELECT * FROM course"; $res = mysql_query($sql) or die(mysql_error()); while ($row = mysql_fetch_assoc($res)) { $courses[] = $row; } $sql = "SELECT * FROM subject"; $res = mysql_query($sql) or die(mysql_error()); while ($row = mysql_fetch_assoc($res)) { $subjects[] = $row; } ?> <form method='post' action='edit.php'> <table width='400' border='5' align='center'> <tr> <td align='center' colspan='5'><h1>Student/Lecturer Course Form</h1></td> </tr> <tr> <td> <select name="course"> <?php foreach($courses as $course) : ?> <option value="<?= $course['course_id'] ?>"> <?= $course['name'] ?> </option> <?php endforeach ?> </select> </td> </tr> <tr> <td> <select name="subject"> <?php foreach($subjects as $subject) : ?> <option value="<?= $subject['subject_id'] ?>"> <?= $subject['name'] ?> </option> <?php endforeach ?> </select> </td> </tr> <input type="hidden" name="user_id" value="<?= $_GET['user_id'] ?>"> <tr> <td colspan='5' align='center'><input type='submit' name='submit' value='Submit' /></td> </tr> </table> </form> </body> </html> <?php mysql_connect("localhost","root",""); mysql_select_db("class_attendance"); if (isset($_POST['submit'])) { print_r( $_POST ); // check all submitted data & make sure we get course_id, subject_id and user_id } ?> and this is my error..
-
Ok i tried to sketch the coding a little bit.. and this is what i got so far.. <?php session_start(); require_once('function.php'); //Set this to what ever page you include that holds all your functions so that we can use the checkUserStatus() checkUserStatus('admin'); ?> <html> <head> <title> Student/Lecturer Course Form </title> </head> <body> <h2 align='right'><a href='admin.php'>Home</a></h2> <form method='post' action='edit.php'> <table width='400' border='5' align='center'> <tr> <td align='center' colspan='5'><h1>Student/Lecturer Course Form</h1></td> </tr> <tr> <td align='center'> <select name="course_id" id="course_id"> <option value="0 selected="selected">Select course</option> <option value=""></option> <option value=""></option> </select></td> </tr> <tr> <td colspan='5' align='center'><input type='submit' name='submit' value='Submit' /></td> </tr> </table> </form> </body> </html> <?php mysql_connect("localhost","root",""); mysql_select_db("class_attendance"); if(isset($_POST['submit'])){ $course_id= $_POST['course_id']; if($course_id==''){ echo "<script>alert('The Course Name is empty!')</script>"; exit(); } $check_name= "select * from user_course where course_id='$course_id'"; $run = mysql_query($check_name); if(mysql_num_rows($run)>0){ echo "<script>alert('The Course Name $course_id already been filled! Please fill another one.')</script>"; exit(); } $query = "insert into user_course (course_id) values ('$course_id')"; if(mysql_query($query)){ echo"<script>alert('Registration successful!')</script>"; } } ?> As you can see, i dont know how to view the clicked user_id to the edit.php and fill the dropdown options with courses that have been added in the course table..
-
Thanx for replying.. Yeah, i already updated my user table to one and this new thread is my new problem.. http://forums.phpfreaks.com/topic/282348-view-name-based-on-user-id-and-stored-coursesubject-option-to-respective-tables/
-
Right now these are my tables.. i have create a page that list all the users and there is an edit button.. My question is when i click the edit button, how to view the name of the user and a select box option where the options are my course and subject that been stored? Then, when i fill the course and subject from the select box, it will stored to user_subject and user_course table.. <?php session_start(); require_once('function.php'); //Set this to what ever page you include that holds all your functions so that we can use the checkUserStatus() checkUserStatus('admin'); ?> <html> <head> <title> View Users </title> </head> <body> <h2 align='right'><a href='admin.php'>Home</a></h2> <center><h2>Users Information</h2><center> <table width='800' align='center' border='5'> <tr bgcolor='yellow'> <th>No.</th> <th>Full Name</th> <th>Matrix No.</th> <th>Username</th> <th>Password</th> <th>User Type</th> <th>Edit User</th> <th>Delete User</th> </tr> <?php mysql_connect("localhost","root",""); mysql_select_db("class_attendance"); $query = "select * from user"; $run = mysql_query($query); while ($row=mysql_fetch_array($run)){ $id = $row[0]; $full_name = $row[1]; $matrix_no = $row[2]; $username = $row[3]; $pass = $row[4]; $type = $row[5]; ?> <tr align='center'> <td><?php echo $id; ?></td> <td><?php echo $full_name; ?></td> <td><?php echo $matrix_no; ?></td> <td><?php echo $username; ?></td> <td><?php echo $pass; ?></td> <td><?php echo $type; ?></td> <td><a href='edit.php?del=<?php echo $id;?>'>Edit</a></td> <td><a href='delete.php?del=<?php echo $id;?>'>Delete</a></td> </tr> <?php } ?> </table> </body> </html>
-
hmmm.. bump.
-
Im now making a simple project called student attendance.. I've just managed the register/login part.. Right now, these are the tables that i created so far.. 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 What i need right now is some advice on how :- The lecturer can select the course_id that have been assigned and then list of subject he/she teach will appear.. Based on what subject he/she clicked, an attendance table appear with list of students in that class and week 1- week XX (checkbox for attendance).. Do i need to assign some primary and foreign key in my tables or adding some more necessary tables?
-
[HTML][PHP][JAVA] login form with select box link to other page
r1nk replied to r1nk's topic in PHP Coding Help
haha no problem.. thanx it works.. =) Finally can move on to the next part.. but one thing that have been bugging me right now.. so i have a table called users (id, name, username, pass, type) right.. lets say in the student page, he/she can view his/her birthday, own cgpa and email.. so i must create another table right.. Now my question is, is it possible when the admin register a student in the database and the username and pass of the students will be add both in the users table and the new created table..? -
[HTML][PHP][JAVA] login form with select box link to other page
r1nk replied to r1nk's topic in PHP Coding Help
owh ok the <?php ?> was missing in the function.php .. i already fixed that and when i tried to login, its just going back to the login page instead of the admin page.. why? -
[HTML][PHP][JAVA] login form with select box link to other page
r1nk replied to r1nk's topic in PHP Coding Help
thanx for replying.. already fixed my login.php.. and now i got this error.. http://i272.photobucket.com/albums/jj178/r1nk_2008/newerror_zpsce7fad20.png -
[HTML][PHP][JAVA] login form with select box link to other page
r1nk replied to r1nk's topic in PHP Coding Help
sorry for late replying.. Got busy with tests.. Ok for the 1st part, i dun get what this means.. header('Location: '.$page); //You may need to edit the path to suit your folder structure. and also for the third part i dont know where to put it in.. So right now these are what i got so far.. function.php function checkUserType($type) { switch($type) { case 'admin': $page = 'admin_page.php'; break; case 'student': $page = 'student.php'; break; case 'lecturer': $page = 'lecturer.php'; break; case 'parents': $page = 'parents.php'; break; } header('Location: '.$page); //You may need to edit the path to suit your folder structure. } function checkUserStatus($actual_page) { //First check to make sure the $_SESSION['type'] is set, if it's not then they haven't logged in so redirect back to login screen if(!isset($_SESSION['type'])) { header('Location: login.php'); } else { if($actual_page == $_SESSION['type']){} else{ checkUserType($_SESSION['type']); } } } login.php <html> <head> <title> Login Form </title> </head> <body> <div style="width: 200px; margin: 200px auto 0 auto;"> <form method='post' action='login.php'> <table width='400' border='5' align='center'> <tr> <td align='center' colspan='5'><h1>Member Login</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 users where username='$username' AND pass='$password'"; $run = mysql_query($check_user); if(mysql_num_rows($run)>0){ echo "<script>window.open('function.php;','_self')</script>"; } else { echo "<script>alert('Username or password is incorrect!')</script>"; } } ?> admin_page.php <?php session_start(); require_once('function.php'); //Set this to what ever page you include that holds all your functions so that we can use the checkUserStatus() checkUserStatus('admin'); ?> <!DOCTYPE html> <html> <head> <title> Admin Page </title> </head> <body> <h2 align='right'><a href='logout.php'>Logout</a></h2> <h2 align='right'><a href='registration.php'>Register User</a></h2> <h2 align='right'><a href='view_users.php'>Delete User</a></h2> </body> </html> -
=,=... help me to view the page..
-
Hey, anyone can run this script perfectly.. I tried to run it using wampp but failed. http://code.google.com/p/student-council-attendance/
-
[HTML][PHP][JAVA] login form with select box link to other page
r1nk replied to r1nk's topic in PHP Coding Help
owh, ok.. thanx i got the concept.. but how to redirect the next page based on the user_type..? "At the top of your admin, student, etc pages you put a if() to check if the user_type is correct for that page and redirect if not." I dun get what u mean by this..