Hey Guys,

I'm just experimenting at the moment - I've made a small application in C# that uses a WebBrowser Control to navigate to a website (which is currently on my LocalHost using WAMP) using a custom UserAgent (HelloWorld)

Now, when I echo the useragent, it tells me what I want to hear. So for example - when I use this code I created:

<?php

echo $_SERVER['HTTP_USER_AGENT'];

?>

it tells me my UserAgent is HelloWorld - which is what I want. But, I want it to display a message. So, I use this code that I've created:

<?php

$ua = $_SERVER['HTTP_USER_AGENT'];
if ($ua="HelloWorld")
     {
        echo "Your Using the C# Application<br/>";
        echo "Success!";
     }
else 
    {
        echo "You're not using the C# Application<br/>";
        echo "Not a Success!";
     }
?>

But when I use Chrome, it still displays the success message - when it shouldn't.

Basically I'm trying to display a message when a SPECIFIC useragent is used.

I'm not having much luck, so all help is appreciated!

Thanks,
Brownie.

That means if ($ua="HelloWorld") is always true. echo the value of $ua before comparison

if ($ua="HelloWorld")

You are using an assignment operator '=' instead of a comparison of equality '=='.

if ("HelloWorld" == $ua) {
  // do stuff
}

I should of known. Thank you madCoder, the extra = sign made all the difference!

If I haven't made it obvious already, I am still learning. But hey, you've got to start someone. Onwards and upwards and learning from my mistakes! :D

Thanks guys for the input! Problem solved!
Brownie.

if ($ua="HelloWorld")

You are using an assignment operator '=' instead of a comparison of equality '=='.

And I didn't even saw that :icon_eek:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.