A demonstration on how to pass values in the URL and how to read them in a secure way
<? // example URL: http://www.example.com/products.php?id=1&name=foo // init the variables $id = 0; $name = ''; if (isset($_GET['id'])) $id = (int) $_GET['id']; if (isset($_GET['name'])) { if (preg_match('/^[a-z]+$/i',$_GET['name'])) $name = $_GET['name']; } ?>
An integer and a string are used, so to show how to handle them securely.
Comments
Add your comment