Índice

Zend PHP Certification Exam: Web Basics

EGPCS

Forms

File uploads

<form enctype="multipart/form-data" action="index.php" method="post">
   <input type="hidden" name="MAX_FILE_SIZE" value="50000" /> // must precede input
   <input name="filedata[]" type="file" />
   <input name="filedata[]" type="file" />
   <select multiple> // for multiple select
      <option value="volvo">Volvo</option>
      <option value="saab">Saab</option>
   </select>
   <input type="submit" value="Send file" />
</form>

HTTP Headers

void header ( string $string [, bool $replace = true [, int $http_response_code ]] )

Cookies

Sessions

HTTP authentication with PHP

if (!isset($_SERVER['PHP_AUTH_USER'])) {
   header('WWW-Authenticate: Basic realm="Secret Area"');
   header('HTTP/1.1 401 Unauthorized'); // this will show the log in box
   echo 'Text to send if user hits Cancel button'; // this will show if the user click cancel in the box
   exit;
} else {
   echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
   echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";
}