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
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
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
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.