Run piece of PHP if Javascript is disabled

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jleague
Forum Newbie
Posts: 2
Joined: Tue Aug 30, 2011 2:36 pm

Run piece of PHP if Javascript is disabled

Post 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
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Run piece of PHP if Javascript is disabled

Post by califdon »

There's a good discussion of this issue at http://stackoverflow.com/questions/1212 ... s-disabled
Jleague
Forum Newbie
Posts: 2
Joined: Tue Aug 30, 2011 2:36 pm

Re: Run piece of PHP if Javascript is disabled

Post 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
Post Reply