0

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.

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by Stefano Mtangoo
0

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

Edited by Stefano Mtangoo: n/a

0
if ($ua="HelloWorld")

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

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

Edited by madCoder: Added example.

0

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.

0
if ($ua="HelloWorld")

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

And I didn't even saw that :icon_eek:

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.