Thursday, 29 January 2015

Using Cookies with PHP

Using Cookies with PHP Cookies allow the webmaster to store information about the site visitor on their computer to be accessed again the next time they visit. One common use of cookies is to store your username and password on your computer so you don't need to login again each time you visit a website. Cookies can also store other things such as your name, last visit, shopping cart contents, etc. The main difference between a cookie and a session is that a cookie is stored on your computer, and a session is not. Although cookies have been...

An Introduction to the PHP DateInterval Class

An Introduction to the PHP DateInterval Class: Date and time manipulation is an unavoidable part of programming; there will inevitably be a part of a project that requires a date to be modified. While, on the surface, echoing a date in the future brings a small bit of accomplishment, it can be quickly eradicated when one is tasked with manipulating that date. Without being aware of the arsenal of tools PHP provides you with regards to working with dates, you might find yourself writing kludges that convert strings into timestamps...

How to validate input variables using filter_input function

<?php/** * PHP filter module * validate input variables using filter_input() function *///creating simple POST form$formPOST = <<<FORM<form method="POST">Enter <b>email</b> for POST validation: <input type="text" name="email" value="{$_POST['email']}"><input type="submit" name="validate" value="validate"></form>FORM;//creating simple GET form$formGET = <<<FORM<form method="GET">Enter <b>url</b> for GET validation: <input type="text" name="url" value="{$_GET['url']}"><input...

PHP - cross-site scripting (XSS)

 cross-site scripting (XSS) Notice that predefining a set of values that are acceptable for a certain parameter is always best. Take an example, we may as well have set the font size in pixels as a parameter and then written that to the document—but then we would have needed a good validation script to prevent end users from sending bad values or even malicious code through the parameter. Sending malicious code via a parameter without...