Jump to content

Recommended Posts

Hey guys, here's my problem-

I am calling a page with a parameter and I want to be able to condition code on that page depending on the parameter.

 

The link i use is this-

<A HREF="test.php?agent=test">

 

the test.php file consists of the following-

 

<?php

echo $_GET['agent'];

if ($agent="blah") {

  echo "Have a nice weekend!";

}

?>

 

the output on that page is-

 

test Have a nice weekend!

 

As you can see, it shouldn't be outputting the "Have a nice weekend!" statement as the agent parameter is "test", not "blah". Any help with this would be appreciated Thanks!

Link to comment
https://forums.phpfreaks.com/topic/56230-solved-need-help-with-parameter/
Share on other sites

in case it's not obvious, jvrothjr added an extra equal sign to your if() condition.  you were using one, which is simply an assignment, which will always evaluate to true.

 

you should also be using $_GET['agent'] in the if().

I tried that code.. It doesn't display the "Have a nice weekend!" at all, which is good because "blah" isn't the value of AGENT. However, when i change code to $agent == "test", it still doesn't display "Have a nice weekend!" even though the condition is true.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.