Hi, I'm modifying a PHP/MySQL driven site which currently has ads hardcoded into the HTML of the pages. I've decided to add PHP sessions and want to remove the ads being shown for people who are logged in. I was hoping for some advice on how this is normally done. I'm doing the coding by hand. Thanks for any help!
Logged into what? I guess I don't understand. If it is all custom written, you would know who is logged in, correct? Then you would just use a conditional. Eric
Well, assuming you set a user id in the session once a user is logged in, it would be as simple as this: if (!empty($_SESSION['user_id'])) { //logged in }Â else { //not logged in } PHP:
yes it should be simple , the logic which your using to check logged in for members should be applied to banners
Hardcoded you say? Uugghh that's gotta be a lot of work and headaches. I hope the banners/ads have divs of their owns so it's at least easier. If you can or have identified these, it's just then a matter of putting in a condition that hides these divs/sections once a member has logged in.
I second the mention of $_SESSION. I question you really need answered is found in the code. Look for a user class or setup of user functions. Then search for any $_SESSION variables, such as, $_SESSION['logged_in'] or $_SESSION['valid']. Once you figure out how the program is validating a "logged-in" user, you can write the "If/Then/Else" statement logic into your header code. Cheers, Jeff
Third Mentioned. IF it's hard coded well you have no choice but to make those fields dynamic, or at the very least place the appropriate if(){ .. } php blocks around the ad placement to accommodate the turning off of the ads. But I would strongly recommend converting to some kind of system that allows you to dynamically manager you ads.