diff --git a/ClassRoster.php b/ClassRoster.php index de3614f..e1ab2be 100644 --- a/ClassRoster.php +++ b/ClassRoster.php @@ -19,22 +19,24 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { //remember the difference between po $errors[] = 'You forgot to enter the course name'; } else { $fn = mysqli_real_escape_string($dbc, trim($_POST['course_name'])); //mysqli_real_escape_strin()escapes special characters in a string for use in an SQL statement. - $sn = mysqli_real_escape_string($dbc, trim($_POST['semester_name'])); - $sy = mysqli_real_escape_string($dbc, trim($_POST['semester_year'])); } if (empty($errors)) { // If there is no errors. If everything's OK. // Make the query: - $q = "SELECT CouLongName, CONCAT(SemesterName, SemesterYear) as SemesterInf, CONCAT(StuLastName, ', ', StuFirstName) as name from Students, Semesters, Courses, StudentClass, ScheduleOfClasses + $q = "SELECT CouLongName, CONCAT(SemesterName, Semesters.SemesterYear) as SemesterInf, CONCAT(StuLastName, ', ', StuFirstName) as name from Students, Semesters, Courses, StudentClass, ScheduleOfClasses WHERE Students.StudentID=StudentClass.StudentID AND ScheduleOfClasses.CourseID=Courses.CourseID AND ScheduleOfClasses.ScheduleID=StudentClass.ScheduleID AND ScheduleOfClasses.SemesterID=Semesters.SemesterID AND - CouLongName='$fn' AND Semesters.SemesterName='$sn' AND Semesters.SemesterYear='$sy'"; + CouLongName='$fn'"; $r = @mysqli_query ($dbc, $q); // Run the query. $num = mysqli_num_rows($r); - if ($num > 0) { // If it ran OK, display the records + if ($num > 0) { // If it ran OK, display the records. + + + + // Print how many users there are: echo "

There is the information for the course you are looking for.

\n"; @@ -63,74 +65,10 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { //remember the difference between po mysqli_close($dbc); // Close the database connection. } // End of the main Submit conditional. ?> +

Class Roster

+
+

Course Name

+

+
-
-
- Class Roster -
- -
- -
-
- - -
- -
- -
-
- - -
- -
- -
-
- - -
-
- -
-
-
-
- - + \ No newline at end of file diff --git a/show_roster.php b/ClassRoster_new.php similarity index 50% rename from show_roster.php rename to ClassRoster_new.php index 7c89739..5c2fd2d 100644 --- a/show_roster.php +++ b/ClassRoster_new.php @@ -19,20 +19,26 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { //remember the difference between po $errors[] = 'You forgot to enter the course name'; } else { $fn = mysqli_real_escape_string($dbc, trim($_POST['course_name'])); //mysqli_real_escape_strin()escapes special characters in a string for use in an SQL statement. + $sn = mysqli_real_escape_string($dbc, trim($_POST['semester_name'])); + $sy = mysqli_real_escape_string($dbc, trim($_POST['semester_year'])); } if (empty($errors)) { // If there is no errors. If everything's OK. // Make the query: - $q = "SELECT CouLongName, CONCAT(SemesterName, Semesters.SemesterYear) as SemesterInf, CONCAT(StuLastName, ', ', StuFirstName) as name from Students, Semesters, Courses, StudentClass, ScheduleOfClasses + $q = "SELECT CouLongName, CONCAT(SemesterName, SemesterYear) as SemesterInf, CONCAT(StuLastName, ', ', StuFirstName) as name from Students, Semesters, Courses, StudentClass, ScheduleOfClasses WHERE Students.StudentID=StudentClass.StudentID AND ScheduleOfClasses.CourseID=Courses.CourseID AND ScheduleOfClasses.ScheduleID=StudentClass.ScheduleID AND ScheduleOfClasses.SemesterID=Semesters.SemesterID AND - CouLongName='$fn'"; + CouLongName='$fn' AND Semesters.SemesterName='$sn' AND Semesters.SemesterYear='$sy'"; $r = @mysqli_query ($dbc, $q); // Run the query. $num = mysqli_num_rows($r); if ($num > 0) { // If it ran OK, display the records. + + + + // Print how many users there are: echo "

There is the information for the course you are looking for.

\n"; @@ -62,9 +68,47 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { //remember the difference between po } // End of the main Submit conditional. ?>

Class Roster

-
-

Course Name

-

+ +

Course Name

+ +
+ +
+

- + \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index ee996fd..0000000 --- a/README.md +++ /dev/null @@ -1 +0,0 @@ -# Helping students make their first PHP-MySQL web form diff --git a/employee.php b/employee.php index f5988bc..f090b68 100644 --- a/employee.php +++ b/employee.php @@ -99,54 +99,15 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { mysqli_close($dbc); // Close the database connection. } // End of the main Submit conditional. + ?> - -
-
- Register - -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- - -
-
- -
-
-
-
- +

Register

+
+

First Name:

+

Last Name:

+

Email Address:

+

Gender:

+

SSN:

+

+
diff --git a/grade.php b/grade.php index 2be44e6..a20e2f7 100644 --- a/grade.php +++ b/grade.php @@ -62,23 +62,10 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { //remember the difference between po } // End of the main Submit conditional. ?> -
-
- Search Course Grade by Student Last Name -
- -
- -
-
- - -
-
- -
-
-
-
+

Search Course Grade by Student Last Name

+
+

Student Last Name

+

+
diff --git a/includes/footer.html b/includes/footer.html index 3809aef..7766696 100644 --- a/includes/footer.html +++ b/includes/footer.html @@ -1,11 +1,8 @@ + - - - - + \ No newline at end of file diff --git a/includes/header.html b/includes/header.html index 97f3e4e..ab76dd8 100644 --- a/includes/header.html +++ b/includes/header.html @@ -1,54 +1,24 @@ - + + - <?php echo htmlspecialchars($page_title);?> - - - - - - - - - - - - - + <?php echo $page_title; ?> + - -
-

Heading of Your Website

-

catchy slogan...

-
- -
- - - - + + +
+ \ No newline at end of file diff --git a/includes/style.css b/includes/style.css new file mode 100644 index 0000000..8710304 --- /dev/null +++ b/includes/style.css @@ -0,0 +1,117 @@ + +* { + border:0; + margin:0; + padding:0; +} + +/* general */ +a { + color:#777; + text-decoration:none; +} + +a:hover { + color:#333; + text-decoration:none; +} + +/* body */ +body { + background:#ffffff; + color:#555; + font:0.8em Arial, Helvetica, "bitstream vera sans", sans-serif; +} + +/* header */ +#header { + border-bottom:1px solid #999; + height:80px; + margin:0 auto; + width:751px; +} +#header h1 { + color:#888; + font-size:300%; + letter-spacing:-3px; + text-align:right; + padding:5px; + margin-bottom:-20px; +} +#header h2 { + color:#CCC; + font-size:200%; + letter-spacing:-2px; + text-align:right; +} + +/* navigation */ +#navigation { + background:#fafafa; + border-right:1px solid #999; + margin:0 auto; + width:750px; + height:40px; + list-style:none; +} +#navigation li { + border-left:1px solid #999; + float:left; + width:149px; + list-style:none; +} +#navigation a { + color:#555; + display:block; + line-height:40px; + text-align:center; +} +#navigation a:hover { + background:#e3e3e3; + color:#555; +} +#navigation .active { + background:#e3e3e3; + color:#777; +} + +/* content */ +#content { + height:auto; + margin:0 auto; + padding:0 0 20px; + width:751px; +} +#content h1 { + border-bottom:1px dashed #999; + font-size:1.8em; + padding:20px 0 0; +} +#content p { + padding:20px 20px 0; +} + +/* footer */ +#footer { + border-top:1px solid #999; + height:50px; + margin:0 auto; + padding:10px; + text-align:center; + width:751px; +} + +/* Added by Larry Ullman: */ +.error, .ad { + font-weight: bold; + color: #C00 +} + +input, select, .input { + padding: 5px; + font-weight: bold; + font-size: 1em; + color: #008040; + background: #FFFFFF; + border:1px dotted #004080; +} \ No newline at end of file diff --git a/index.php b/index.php index c8ddce1..73d0b57 100644 --- a/index.php +++ b/index.php @@ -1,20 +1,17 @@ - - -

Big Header

+

Big Header

This is where you'll put the main page content. This content will differ for each page.

This is where you'll put the main page content. This content will differ for each page.

This is where you'll put the main page content. This content will differ for each page.

This is where you'll put the main page content. This content will differ for each page.

-

Subheader

This is where you'll put the main page content. This content will differ for each page.

This is where you'll put the main page content. This content will differ for each page.

This is where you'll put the main page content. This content will differ for each page.

This is where you'll put the main page content. This content will differ for each page.

- +?> \ No newline at end of file diff --git a/instructions.txt b/instructions.txt new file mode 100644 index 0000000..5be9d7a --- /dev/null +++ b/instructions.txt @@ -0,0 +1,38 @@ +Modifying PHP code to communicate with your database + + (1). Please download Lab10.zip from Moodle, and unzip the files onto your computer. You will see multiple HTML files, css files and php files in the folder. + + (2). You will see the following pages: + a. mysqli_connect.php: makes connection to the database account. Pages that will communicate with your MySQL database will need to use this file in order to connect. + b. index.php: the main page of the website + c. grade.php: retrieve course grade information for a student. + d. employee.php: insert a new lecturer into the database. + e. search.php: search lecturers and students by names + f. ClassRoster.php: retrieve the class roster for a specific course + g. The includes folder: + i. header.html: the header (log, navigation bar, etc.) section of each page on this website + ii. footer.html: the footer section of each page on this website + iii. style.css: the overall style of the website. +Please note that there are detailed comments in each php page. Make sure you read them carefully and understand what each proportion of PHP does. + + (3). Please open the mysqli_connect.php file using a text editor. If you are on Windows, you can use Komodo Edit, Notepad++, PHP Storm, Eclipse, etc. If you are on Mac, you can use TextWrangler, Komodo Edit, Eclipse, etc. In the editor window, please modify the code accordingly so that the connection will be made to your own database on simmons server. + + (4). Please upload all the files (but this word document) to LIS458 folder that you created under public_html. Make sure the folder called “include” is also moved to LIS458. + + (5). Open a browser and type the following information to the address bar: +web.simmons.edu/~your username/LIS458/index.php +You should see the following page in the browser. Click the navigation section and take a look at each page. + + (6). Please do the following task on each page: + a) On ClassRoster Page, please search the class roster information for “Computer Networks”. What does it return? Take a screenshot of the result and paste it below. + + b) On New Employee Register page, insert a new lecturer with last name=”Smith”, first name=”Cecilia”, email=cecilia@test.com, gender=”female” and ssn=”1243568790”. What is the message returned? Take a screenshot and paste it below. + + c) On the Course Grade page, please search for course grade for a student with last name=”Mcneil”. Take a screenshot of the returned result and paste it below. + + d) On the Search People page, please search for a student with first name=” Irene”. Take a screenshot for the result and paste it below. Then search for a lecturer with last name=”Lowe”. Paste the result below. + + + (7). Please modify the search people page, so that you can search by lecturer last name or lecturer email address. Make sure you upload the modified search.php code onto Simmons server to overwrite the original one. Then you can search from your browser to see if the change works. + + (8). Please modify the Class Roster page so that it allows search by Course Name and Semester Information. Please provide a list of semesters for users to select from (recall drop-down menu from the first lab). Similarly, upload the modified page to Simmons server and revisit it from your browser. diff --git a/register.php b/register.php new file mode 100644 index 0000000..088c672 --- /dev/null +++ b/register.php @@ -0,0 +1,110 @@ +Thank you! +

You are now registered. In Chapter 12 you will actually be able to log in!


'; + + } else { // If it did not run OK. + + // Public message: + echo '

System Error

+

You could not be registered due to a system error. We apologize for any inconvenience.

'; + + // Debugging message: + echo '

' . mysqli_error($dbc) . '

Query: ' . $q . '

'; + + } // End of if ($r) IF. + + mysqli_close($dbc); // Close the database connection. + + // Include the footer and quit the script: + include ('includes/footer.html'); + exit(); + + } else { // Report the errors. + + echo '

Error!

+

The following error(s) occurred:
'; + foreach ($errors as $msg) { // Print each error. + echo " - $msg
\n"; + } + echo '

Please try again.


'; + + } // End of if (empty($errors)) IF. + + mysqli_close($dbc); // Close the database connection. + +} // End of the main Submit conditional. +?> +

Register

+
+

First Name:

+

Last Name:

+

Email Address:

+

Password:

+

Confirm Password:

+

+
+ diff --git a/search.php b/search.php index ba79cbd..8919502 100644 --- a/search.php +++ b/search.php @@ -57,25 +57,11 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { //remember the difference between po mysqli_close($dbc); // Close the database connection. } // End of the main Submit conditional. ?> - -
-
- Search Students by First Name -
- -
- -
-
- - -
-
- -
-
-
-
+

Search Students by First Name

+
+

First Name

+

+
-
-
- Search Lecturers by Last Name -
- -
- -
-
- - -
-
- -
-
-
-
- +

Search Lecturers by Last Name

+
+

Last Name

+

+
diff --git a/search_email.php b/search_email.php new file mode 100644 index 0000000..d069e9f --- /dev/null +++ b/search_email.php @@ -0,0 +1,175 @@ + 0) { // If it ran OK, display the records. + + // Print how many users there are: + echo "

There is the information for the student you are looking for.

\n"; + + // Table header. + echo ' + +'; + + // Fetch and print all the records: + while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { //MYSQLI_ASSOC makes the returned array assortative. + echo ' + '; + } + + echo '
NameEmailMobile
' . $row['name'] . '' . $row['StuEmail'] . '' . $row['Mobile'] . '
'; // Close the table. + } + else { // If it did not run OK. + + // Public message: + echo '

Error

+

There is no student match with the information you provided

'; + + } + } + + mysqli_close($dbc); // Close the database connection. + } // End of the main Submit conditional. +?> +

Search Students by First Name

+
+

First Name

+

+
+ + 0) { // If it ran OK, display the records. + + // Print how many lecturers there are: + echo "

There is the information for the lecturer you are looking for.

\n"; + + // Table header. + echo ' + +'; + + // Fetch and print all the records: + while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { //MYSQLI_ASSOC makes the returned array assortative. + echo ' + '; + } + + echo '
NameEmailTelphone
' . $row['lecname'] . '' . $row['LecEmail'] . '' . $row['WTel'] . '
'; // Close the table. + } + else { // If it did not run OK. + + // Public message: + echo '

Error

+

There is no lecturer match with the information you provided

'; + + } + } + + mysqli_close($dbc); // Close the database connection. + } // End of the main Submit conditional. +?> + + 0) { // If it ran OK, display the records. + + // Print how many lecturers there are: + echo "

There is the information for the lecturer you are looking for.

\n"; + + // Table header. + echo ' + +'; + + // Fetch and print all the records: + while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { //MYSQLI_ASSOC makes the returned array assortative. + echo ' + '; + } + + echo '
NameEmailTelphone
' . $row['lecname'] . '' . $row['LecEmail'] . '' . $row['WTel'] . '
'; // Close the table. + } + else { // If it did not run OK. + + // Public message: + echo '

Error

+

There is no lecturer match with the information you provided

'; + + } + } + + mysqli_close($dbc); // Close the database connection. + } // End of the main Submit conditional. +?> + +

Search Lecturers by Last Name

+
+

Last Name

+

+

Lecture Email

+

+
+