I am trying to setup a PHP snippet that checks if 2 conditions are met and if they are, it echoes some text. The conditions are:
- That the query string equals a certain value.
- That the browser is Firefox.
It’s checking the query string properly but, it doesnt seem to be working for the browser (user agent). See below:
<?php
function get_user_browser()
{
$u_agent = $_SERVER['HTTP_USER_AGENT'];
$ub = '';
if(preg_match('/Firefox/i',$u_agent))
{
$ub = "firefox";
}
else
{
$ub = "other";
}
}
if (isset($_GET['print']) && $_GET['print'] != "" && $ub = 'firefox')
{
$pg = $_GET['print'];
if (!file_exists('1'))
{
echo '<b>It worked!</b>';
}
}
else
{
echo '';
}
?>
Any help would be appreciated.
This is what i do to check out that stuff:
And added into your code: