Need Help in PHP

Reply

Join Date: Apr 2008
Posts: 109
Reputation: architact is an unknown quantity at this point 
Solved Threads: 7
architact's Avatar
architact architact is offline Offline
Junior Poster

Need Help in PHP

 
0
  #1
Aug 14th, 2008
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
If you think we fight for money and you fight for honor, then remember everyone fights for the thing they don't have...
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 849
Reputation: R0bb0b is on a distinguished road 
Solved Threads: 67
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Practically a Posting Shark

Re: Need Help in PHP

 
0
  #2
Aug 15th, 2008
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.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss

-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 109
Reputation: architact is an unknown quantity at this point 
Solved Threads: 7
architact's Avatar
architact architact is offline Offline
Junior Poster

Re: Need Help in PHP

 
0
  #3
Aug 15th, 2008
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
If you think we fight for money and you fight for honor, then remember everyone fights for the thing they don't have...
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 849
Reputation: R0bb0b is on a distinguished road 
Solved Threads: 67
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Practically a Posting Shark

Re: Need Help in PHP

 
0
  #4
Aug 15th, 2008
Originally Posted by architact View Post
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
  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:
  1. document.getElementById('btn').style.display = 'block';
or
  1. document.getElementById('btn').style.display = 'inline';
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss

-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 381
Reputation: langsor is an unknown quantity at this point 
Solved Threads: 33
langsor langsor is offline Offline
Posting Whiz

Re: Need Help in PHP

 
1
  #5
Aug 15th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 109
Reputation: architact is an unknown quantity at this point 
Solved Threads: 7
architact's Avatar
architact architact is offline Offline
Junior Poster

Re: Need Help in PHP

 
0
  #6
Aug 15th, 2008
Thanks a lot for the solution
same can be used for an image or table?
If you think we fight for money and you fight for honor, then remember everyone fights for the thing they don't have...
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 849
Reputation: R0bb0b is on a distinguished road 
Solved Threads: 67
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Practically a Posting Shark

Re: Need Help in PHP

 
0
  #7
Aug 15th, 2008
Originally Posted by architact View Post
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.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss

-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 381
Reputation: langsor is an unknown quantity at this point 
Solved Threads: 33
langsor langsor is offline Offline
Posting Whiz

Re: Need Help in PHP

 
0
  #8
Aug 15th, 2008
Any html element can be hidden/shown using this method.

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

Ciao
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 109
Reputation: architact is an unknown quantity at this point 
Solved Threads: 7
architact's Avatar
architact architact is offline Offline
Junior Poster

Re: Need Help in PHP

 
0
  #9
Aug 15th, 2008
I am using php but i haven't figured out how to hide elements based on security, can you suggest what to do?
If you think we fight for money and you fight for honor, then remember everyone fights for the thing they don't have...
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 849
Reputation: R0bb0b is on a distinguished road 
Solved Threads: 67
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Practically a Posting Shark

Re: Need Help in PHP

 
0
  #10
Aug 15th, 2008
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.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss

-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC