Skip to content

Instantly share code, notes, and snippets.

@CeoFred
Created June 4, 2019 02:27
Show Gist options
  • Select an option

  • Save CeoFred/eb1be27db8d7953540c3e6542e0e9090 to your computer and use it in GitHub Desktop.

Select an option

Save CeoFred/eb1be27db8d7953540c3e6542e0e9090 to your computer and use it in GitHub Desktop.
Filter Request Data
function sanitize($data){
trim($data);
htmlspecialchars($data);
htmlentities($data);
strip_tags($data);
return $data;
}
foreach ($_REQUEST as $key => $value) {
sanitize($value);
}
//use them as normal
$facebook_link = isset($_REQUEST['facebook_url']) ? $_REQUEST['facebook_url'] : null;
$twitter_link = isset($_REQUEST['twitter_url']) ? $_REQUEST['twitter_url'] : null;
$linkedin = isset($_REQUEST['linkedin_url']) ? $_REQUEST['linkedin_url'] : null;
$website = isset($_REQUEST['website_url']) ? $_REQUEST['website_url'] : null;
$fax = isset($_REQUEST['fax']) ? $_REQUEST['fax'] : null;
$logo = isset($_FILES['logo']) ? $_FILES['logo'] : null;
$rcc = isset($_REQUEST['reg_no']) ? $_REQUEST['reg_no'] : null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment