Hello everyone! I could really use some help with a MySQL/PHP coding issue. I working on a grade book for a friend at a local elementary school. I'm stuck. Please Help!
I have an html login form:
<form action="StuGetIn.php" method="POST">
Student ID:
<input type="text" name="StuUserID" size="14">
Password:
<input type="password" name="StudPassword" size="14">
<input type="image" src="../Images/Go.gif"></form>
The values entered in the text boxes are sent to the StuGetIn.php page as follows:
<?
// connect to the database
$conn = mysql_connect("localhost","databaseUsername","databasePassword");
$db = mysql_select_db("databaseName");
// declare values from form
$username = $POST["StuUserID"];
$password = $POST["StudPassword"];
// connect to User_Info table to see if the login is correct
$result = MYSQL_QUERY("SELECT * from User_Info WHERE StuID='$username'and Password='$password'")
or die ("Name and password not found or not matched");
$worked = mysql_fetch_array($result);
$username = $worked[StuID];
$password = $worked[Password];
$fname = $worked[FirstName];
$lname = $worked[LastName];
$cname = $worked[ClassName];
$glevel = $worked[GradeLevel];
$assign = $worked[Assignment];
$grade = $worked[Grade];
$comments = $worked[Comments];
$dposted = $worked[DatePosted];
if($worked) {
include "header.php";
echo "<br><center>Welcome $fname!</center><br><div align=center>
<center>
<table border=1 cellpadding=0 cellspacing=0 style=border-collapse: collapse bordercolor=#111111 id=AutoNumber1>
<tr>
<td>Class Name</td>
<td>Assignment</td>
<td>Grade</td>
<td>Date Posted</td>
<td>Comments</td>
</tr>
<tr>
<td>$cname</td>
<td>$assign</td>
<td>$grade</td>
<td>$dposted</td>
<td>$comments</td>
</tr>
</table>
</center>
</div><br>";
include "footer.php";
} else {
include "header.php";
echo "<br><br><b><center>Sorry, Name and password not found or not matched</center></b><br><br>";
include "footer.php";
}
?>
The problem is that I have two tables which need to be joined but are not joined yet because I don't know how to test the username and pasword entered in the login form from the User_Info table and display the values from the other table. At the same time I have to check the login info from one and get the value from the other.
User_Info table: StuId, TeachID, Password, GradeLevel
GradeBook table: FirstName, LastName, ClassName, Grade, Comment, DatePosted
Please help me join these tables!!!!!!!!!!!! Thank you fellow PHP/MySQL fans.