Trusted by +2 million users,
1000+ happy students everyday
Showing pages 1 to 3 of 7 pages
readAll.php<html><head><title>Read all records</title></head><body><form method="post" action="readAll_hint.php"><input type="submit" value="Show All Enrollments"></form></body></html><?phpif($_SERVER['REQUEST_METHOD'] == "POST"){//Code to connect to the database$query = "SELECT EnrollmentID, course.CourseID, course.Title,course.Credits,student.StudentID, student.LastName, student.FirstName, Grade,EnrollmentSemesterFROM enrollmentINNER JOIN course ON course.CourseIDINNER JOIN student ON student.StudentIDWHERE enrollment.CourseID = course.CourseID ANDenrollment.StudentID = student.StudentIDORDER BY student.LastName";//Code to run the query and retrieve necessary data and showthem on the web page}?>Select.php<html><head><title>Read selected records</title></head><body><form method="post" action="select_hint.php">Title: <input type="text" name="courseTitle"><br />Last Name: <input type="text" name="studentLastName"><br /><input type="submit" value="Show Enrollments"></form></body></html><?php//Define a sanitize function to sanitize user's inputsif(isset($_POST['courseTitle']) && isset($_POST['studentLastName']))
{//Code to connect to the DB//Code to sanitize inputs$query = "SELECT student.LastName, course.Title, Grade,EnrollmentSemesterFROM enrollmentINNER JOIN course ON course.CourseIDINNER JOIN student ON student.StudentIDWHERE enrollment.CourseID = course.CourseID ANDenrollment.StudentID = student.StudentIDAND course.Title LIKE '%$sanitizedCourseTitle%' ANDstudent.LastName LIKE '%$sanitizedStudentLastName%'";//Code to run the query and retrieve necessary data and showthem on the web page.}?>createStudent.php<html><head><title>Insert Student</title></head><body><h1>Create new Student</h1><form method="post" action="createStudent_sol.php" ><label for="fname_field">First Name: </label><input id="fname_field" type="text" name="firstName" /><br /><br /><label for="lname_field">Last Name: </label><input id="lname_field" type="text" name="lastName" /><br /><br /><input type="submit" value="Add New Student" /></form><?phpif($_SERVER['REQUEST_METHOD'] == "POST"){//Code to connect to the DB//Code to retrieve the highest value of Student ID currentlyin the DBif(isset($_POST['firstName']) &&isset($_POST['lastName']=="")){//Santize inputs$query = "INSERT INTO student VALUES('$studentID','$firstName', '$lastName')";
//Run the query of insertion}//Define a input sanitize function?>Gradechange.php<html><head><title>Change Grade</title></head><body><h1>Change Grade</h1><form method="post" action="gradeChange_sol.php" ><label for="studentID_field">Student ID: </label><input id="studentID_field" type="text" name="studentID" /><br /><br /><label for="courseID_field">Course ID: </label><input id="courseID_field" type="text" name="courseID" /><br /><br /><label for="enrollment_field">Enrollment Semester (format: FA17): </label><input id="enrollment_field" type="text" name="enrollmentSemester"size="4"/><br /><br /><label for="grade_field">New Grade: </label><input id="grade_field" type="text" name="newGrade" size="3"/><br /><br /><input type="submit" value="Update Grade" /></form><?phpif($_SERVER['REQUEST_METHOD'] == "POST"){//Code to connect to DBif(isset($_POST['studentID']) && isset($_POST['courseID']=="")&& isset($_POST['enrollmentSemester']=="") && isset($_POST['newGrade']=="")){//Code to sanitize inputs$query = "UPDATE enrollment SET Grade='$newGrade' WHEREStudentID='$studentID' AND CourseID='$courseID' ANDEnrollmentSemester='$enrollmentSemester'";//Code to run the query of UPDATE}}//Define a input sanitize function?>
desklib-logo
You’re reading a preview
Preview Documents

To View Complete Document

Click the button to download
Subscribe to our plans

Download This Document