Presentation is loading. Please wait.

Presentation is loading. Please wait.

Various Notes on PHP Several useful tidbits not discussed in class.

Similar presentations


Presentation on theme: "Various Notes on PHP Several useful tidbits not discussed in class."— Presentation transcript:

1 Various Notes on PHP Several useful tidbits not discussed in class

2 Header The PHP function header(string) is used to send a raw HTTP header to the browser Most useful for redirecting the browser to another page (after a successful login, for example) <?php // string storing the destination $url = http://www.uottawa.cahttp://www.uottawa.ca /* Sends a header telling the browser to navigate to $url */ header(“Location: “. $url); ?>

3 IMPORTANT NOTE! It is absolutely vital that any calls to header(…) must be made before any other output is sent to the browser (either by standard HTML tags, HTML comments, PHP’s echo command, or even blank lines. Failure to ensure this will result in an error when your PHP script runs

4 Preventing Browser-caching The header(…) function can also be used to prevent the browser from caching the data sent by PHP. This forces the browser to refresh the page everytime the page is loaded.

5 Anti-caching example

6 MD5 Hashing The PHP Function md5(string) takes a string parameter and returns the md5 hash of that string (a 32-bit hexadecimal number) This function does not encrypt the data sent to it, it merely returns a hash-value for that data. <?php $password = ‘tomatePotate'; if (md5($password) === /*MD5 of password stored in file*/) { echo “The passwords match!” } ?>

7 Resources PHP function header(…) http://www.php.net/manual/en/function.heade r.php http://www.php.net/manual/en/function.heade r.php PHP function md5(…) http://www.php.net/manual/en/function.md5.p hp RSA MD5 Message Digest Algorithm http://www.faqs.org/rfcs/rfc1321 http://www.faqs.org/rfcs/rfc1321


Download ppt "Various Notes on PHP Several useful tidbits not discussed in class."

Similar presentations


Ads by Google