0

My address is www.mysite.com/test-url?tx=test

if (isset($_GET['tx'])) {
    echo 'Success';

 }

However nothings happening at all, its simply not reading the fact that the variable is there

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Adrian
  • 1,976
  • 5
  • 41
  • 105

2 Answers2

0

Looks like you're using mod_rewrite in your .htaccess file,

so, where you'll have something like this in your .htaccess:

RewriteRule ^([^/\.]+)?$ index.php?page=$1 [L]

You'll need to add QSA like this:

RewriteRule ^([^/\.]+)?$ index.php?page=$1 [L,QSA]
                                             ^^^^

This tells the server to append the query string.. more info at apache.org

0

From what I saw in a comment you wrote, you mentioned that you're on WordPress.

TBH, I'm not a Wordpress guy therefore I wouldn't be able to help and troubleshoot it in a greater scope, but do try the following by adding an extra conditional statement to match the word test in the GET.

The following was successful on my server (not Wordpress). If the URL was test-url?tx= it would fail and if it were test-url?tx=testx it would also fail, therefore only test-url?tx=test will be deemed as successful.

<?php
if (isset($_GET['tx']) && $_GET['tx'] == test) {
    echo 'Success.';

 }

else {
echo "Sorry, the parameter is not set or is invalid.";
}

Edit

Have a look at this and this Q&A where I found the first one from.

I Google'd "if (isset($_GET not working with wordpress php" here you will find many other results, am sure.

Community
  • 1
  • 1
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
  • Thanks but it must definitely something to do with wordpress because this didnt work either for some reason – Adrian Mar 12 '14 at 17:02
  • You're welcome Adrian. I wish I could help you further, but as I stated (in my answer) I'm not a Wordpress guy, and thought that by adding the additional conditional statement, that it would have helped. @Adrian – Funk Forty Niner Mar 12 '14 at 17:03
  • You're welcome @Adrian - If I think of anything (or find) I'll let you know. – Funk Forty Niner Mar 12 '14 at 17:08
  • [`Have a look at this`](http://www.rlmseo.com/blog/passing-get-query-string-parameters-in-wordpress-url/) and [`this Q&A`](http://stackoverflow.com/q/4586835/) where I found the first one from. I Google'd `"if (isset($_GET not working with wordpress php"` @Adrian where you will find many other results, am sure. – Funk Forty Niner Mar 12 '14 at 17:12
  • feel free to edit your answer with the link and Ill give it a tick :) cheers – Adrian Mar 13 '14 at 10:04