943,715 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 951
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Aug 14th, 2008
0

Need Help in PHP

Expand Post »
Hello, I have designed a website that has some things for only registered users. I have javascript to hide these object if the user is not logged in using <body onload="a();">. But the problem is that when the page loads these items show up for a while and then hide I want to stop that.

Thanks
Reputation Points: 40
Solved Threads: 7
Junior Poster
architact is offline Offline
114 posts
since Apr 2008
Aug 15th, 2008
0

Re: Need Help in PHP

What you are probably doing is setting the default action to shown when the default action should be hidden. Then if a user is logged in the hidden items are then shown rather than the other way around.
Reputation Points: 358
Solved Threads: 89
Posting Shark
R0bb0b is offline Offline
986 posts
since Jun 2008
Aug 15th, 2008
0

Re: Need Help in PHP

Thanks for quick reply.

for example i want to hide a button from unregistered users, but it shows up fro 4-5 seconds and then hides.
i am using
document.getElementById('btn').style.visibility = 'none';

on body load
Reputation Points: 40
Solved Threads: 7
Junior Poster
architact is offline Offline
114 posts
since Apr 2008
Aug 15th, 2008
0

Re: Need Help in PHP

Click to Expand / Collapse  Quote originally posted by architact ...
Thanks for quick reply.

for example i want to hide a button from unregistered users, but it shows up fro 4-5 seconds and then hides.
i am using
document.getElementById('btn').style.visibility = 'none';

on body load
Right, exactly, you are waiting until the page fully loads until you hide the button with your page load event. You should use
html Syntax (Toggle Plain Text)
  1. <input id="btn" type="button" style="display:none" />
Then your javascript onload event will check if the user is authenticated and display the button with:
javascript Syntax (Toggle Plain Text)
  1. document.getElementById('btn').style.display = 'block';
or
javascript Syntax (Toggle Plain Text)
  1. document.getElementById('btn').style.display = 'inline';
Reputation Points: 358
Solved Threads: 89
Posting Shark
R0bb0b is offline Offline
986 posts
since Jun 2008
Aug 15th, 2008
1

Re: Need Help in PHP

You've got the answer above, but remember that people can "view source" and see things hidden from the page display...just a thought to keep in mind.
Reputation Points: 30
Solved Threads: 36
Posting Whiz
langsor is offline Offline
389 posts
since Aug 2008
Aug 15th, 2008
0

Re: Need Help in PHP

Thanks a lot for the solution
same can be used for an image or table?
Reputation Points: 40
Solved Threads: 7
Junior Poster
architact is offline Offline
114 posts
since Apr 2008
Aug 15th, 2008
0

Re: Need Help in PHP

Click to Expand / Collapse  Quote originally posted by architact ...
Thanks a lot for the solution
same can be used for an image or table?
Yes you can, and as langsor stated, this is not for security, if you are trying to restrict access to something you should go with a server side solution. This will only hide it from plain site, but just remember that it is not hard to view all of your javascript no matter where you are pulling it from. Even if you don't see the javascript in the source and are getting it from another file, it can be read with things like the "web developer" add on with firefox and other applications.
Last edited by R0bb0b; Aug 15th, 2008 at 12:55 am.
Reputation Points: 358
Solved Threads: 89
Posting Shark
R0bb0b is offline Offline
986 posts
since Jun 2008
Aug 15th, 2008
0

Re: Need Help in PHP

Any html element can be hidden/shown using this method.

Images are 'inline' elements
Table are 'block' elements

Ciao
Reputation Points: 30
Solved Threads: 36
Posting Whiz
langsor is offline Offline
389 posts
since Aug 2008
Aug 15th, 2008
0

Re: Need Help in PHP

I am using php but i haven't figured out how to hide elements based on security, can you suggest what to do?
Reputation Points: 40
Solved Threads: 7
Junior Poster
architact is offline Offline
114 posts
since Apr 2008
Aug 15th, 2008
0

Re: Need Help in PHP

If you are looking for a server side security mixed with the wonders of javascript then an ajax solution would be the way to go.
Reputation Points: 358
Solved Threads: 89
Posting Shark
R0bb0b is offline Offline
986 posts
since Jun 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: data insertion problem in php
Next Thread in PHP Forum Timeline: confirmation box





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC