We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

fris on 08/16/08


Tagged

url parse String values


Versions (?)


Who likes this?

2 people have marked this snippet as a favorite

brent-man
luman


secure way to pass values in url


Published in: PHP 


  1. <?
  2.  
  3. // example : http://www.site.com/article.php?id=1&name=funny
  4.  
  5. $id = 0;
  6. $name = '';
  7.  
  8. if (isset($_GET['id'])) $id = (int) $_GET['id'];
  9. if (isset($_GET['name']))
  10. {
  11. if (preg_match('/^[a-z]+$/i',$_GET['name'])) $name = $_GET['name'];
  12. }
  13. ?>

Report this snippet 

You need to login to post a comment.