Uploaded Files

The $_FILES array contains the name, type, size, tmp_name, and error (the error code for the file transfer). I need to make sure my file uploaded uses these values and saves them to a log somewhere, maybe the error handler.

You can also add a hidden input field to store max file size in the HTML form.

  • Once uploaded the file exists and we can use getimageinfo() to determine
  • 0 width in pixels
  • 1 height in pixels
  • 2  numerical value for the image type*
  • 3 string to use in HTML image tag (height="" width="")
  • 4 mime type of image
*2 is made easier to use with some predefined constants for the type of file.

The book suggests adding the URL error.php?400 wherein the 400 is an error code so you can use one file for all the web page errors. Put a switch in the body of the page to handle different HTML formats.

set_error_handler( name of error function) Make an error handler that can catch all errors for later use. Add in an error type check to switch through the different levels of error.

Exceptions can be rethrown. You can get all the PHP exceptions and send them all to one single place. Catch(Exception $e) 

Throw $e
 
Print_r $_POST
 
$row = MySQL fetch array()
extract($row)
Then you use the variables as listed in row.
 
Function rediredt($url)
If !headers_sent()
Header('Location: '.$url)
Else die('could not redirect')
 

They suggest setting up a user transaction file. It would then switch between login, logout, and create an account, modify account, delete the account, forgot password, etc. there'd example is a request for 'action'. Likewise publishing as a transaction is save changes, publish, retract, delete, add new.

The authors also included a list of recommended hosting providers.

Beginning PHP5, Apache, and MySQL Web Development

by Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec

Wiley | February 4, 2005 | Trade Paperback

These are notes I made after reading this book. See more book notes

Just to let you know, this page was last updated Tuesday, Mar 19 24