LD01: Intro to PHP due Thu 18 Jan 13:20

\begin{purpose}
In this assignment you will:
\begin{itemize}
\item Get set u...
...x.edu.
\item Learn to read/use PHP documentation
\end{itemize}
\end{purpose}

PreLab

Prior to attending lab day complete these steps:

Lab Day

  1. At the beginning of the period show your prep work to the instructor.

  2. In this lab session we will be taking steps toward the homework assignment in which you will have a web scraper that will accept an old-fashioned ISBN-10 (not the newer ISBN-13) value, look it up at amazon.com, and extract some information from it.

  3. Copy hello.php to form.php. In form.php create a form that allows a user to enter an ISBN (text box), the condition of a book (drop down with 4=excellent, 3=good, 2=fair, 1=poor), and a price (text box). Have the form action post to a php document called scraper.php.

  4. Create scraper.php (by copying hello.php). Have it extract the ISBN from the form data using the $_POST array and display it to the screen.

  5. Modify scraper.php so that it will remove any dashes from the ISBN. HINT: Do a web search for “php str_replace” and read the documentation that explains this function.

  6. Once the ISBN has the dashes removed use the preg_match function to determine whether or not it contains 10 digits and contains only digits (with the exception that the final digit may be an “x” (either upper- or lower-case). If the ISBN is valid by these rules display the number. If it is not valid say: “Not valid”.

  7. In the hw01 directory create a text file named poem.txt that contains 4 or 5 lines of whatever you want.

  8. In the body of scraper.php use PHP commands (fopen, fgets, and fclose) to create a loop to read the poem file one line at a time and then display those lines on the page. NOTE: The poem should be displayed only if the provided ISBN number is valid.

  9. Show your work to the instructor. If you finish early, take time to begin work on the homework assignment.