Page 1 of 1

Run piece of PHP if Javascript is disabled

Posted: Tue Aug 30, 2011 3:10 pm
by Jleague
Hi there,

I have a login script in PHP that works very well and redirects the user back to the page they requested before login.
What I have done recently is added some Javascript to give instant errors if the user inputs something wrong, This is working as expected also.

What I would like to do is run a very small piece of PHP code only if Javascript is disabled but not to run otherwise.
This is because I am trying to make my site seamless for those who have javascript disabled also...

The piece of code on my PHP page is:

Code: Select all

$returntopage = 'pageiwant.php';
include('anotherpage.php');
Now I was wondering if there were an easy way to only run the above if javascript is disabled?
I have tried <noscript> tags around it but that did not work...

I know there is no way in PHP to check if javascript is disabled or not but was hoping someone here would have another idea for just including the above in my php page if javascript is disabled?

thanks for any help and if you need more info please ask...

Many Thanks

Re: Run piece of PHP if Javascript is disabled

Posted: Tue Aug 30, 2011 4:57 pm
by califdon
There's a good discussion of this issue at http://stackoverflow.com/questions/1212 ... s-disabled

Re: Run piece of PHP if Javascript is disabled

Posted: Wed Aug 31, 2011 11:52 am
by Jleague
califdon wrote:There's a good discussion of this issue at http://stackoverflow.com/questions/1212 ... s-disabled
That is a good discussion, thanks for the link, it has gave me a few ideas I hadn't thought of. :D