PHP search engine practical
- Write a web page
on the Linux server
- Your page has a
in which you can type a search term.
- When you click submit, a server-side PHP program
is called with the search term
as an argument.
- Read the Shakespeare contents page into a string.
(Research how to read a file into a string in PHP.)
- Search that string for the search term the user entered.
(Research how to search for one string in another string in PHP.)
- While you will search the offline version,
if there is a hit,
I want you to link to the page in the online version.
For example, Macbeth is:
- You should do a case-insensitive search.
(But note that University of Adelaide site is case-sensitive.)
e.g. Uppercase search term:
should match and lead to lowercase URL above.
For top marks
For the very top marks, we expect some students to add their own unique twist.
- The basic program would be like this:
- If the user types "macbeth" we search for "macbeth/index.html" in the contents file. So this should succeed.
- If the user types "henry" we search for "henry/index.html" in the contents file. So this should fail.
- For top marks, you should make some kind of enhancement to the basic program.
- One obvious enhancement (but not the only possible one) would be to do a partial match:
- For example, if the user types "henry", we say there is no play called "henry" but maybe you meant one of the following ...
and have links to the n different plays that have "henry" in their name.
- There are other enhancements you could make.
If you make any enhancements to the basic program, please make sure I notice them by
listing them clearly in comments at the top of your program code.
What this illustrates
- Server side code.
- Code hidden from user.
- Passing arguments from forms to your program.
- Accessing private files/databases on the server side.
- Outputting HTML dynamically. Web page is the output of running a program.
What to submit
- Your page should be running at some URL.
You should keep this URL secret from others.
Do not use file.html
Tell me in your documentation where it is though, so I can try it out.
- Your documentation should have:
- Name and IDs of student(s).
- URL of page so I can try it out.
- Printout of code.
- Printout of code should be:
- Fixed-width font.
- Landscape mode.