rewriting a splash page; using sessions, changing links

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
marshpixie
Forum Newbie
Posts: 9
Joined: Sat Jan 09, 2010 6:24 am

rewriting a splash page; using sessions, changing links

Post by marshpixie »

Hello. I have googled and read till I'm blue in the face but I can't find what I need. The problem is, I'm soooo new to php so here is the long story...

I have done plenty of html/css stuff and that's fine. Recently someone asked me to redesign their splash page. Great. At the moment it is a basic splash with info about the site (adult literature} and it has two buttons. "No I'm not 18" goes to google and "yes I am 18" goes to the main site. At the moment, it sets a cookie ans starts a session so that once the user is in the main site, when they click for home, they go to the index page not back to the splash page.

The redesign involved putting loads more links onto the splash page because it's otherwise quite sterile and offputting. I have a disclaimer up which says "clicking on ANY of these links certifies that you are over 18, yadda yadda" and I want each link to go into the site.

The current code in the header reads:

Code: Select all

<?PHP
 
setcookie("ageauth", "yes" , 0);
 
//call session_start() to have access to SESSION[...] variables
session_start();
 
// Set this to the default value in case the $_SESSION['original_user_url'] isn't set
$enterUrl = "http://www.loveyoudivine.com/";
 
//If the original_user_url is presesnt in the session, get it and use it to make the link for the "Enter" button.
if (isset($_SESSION['oringal_user_url'])) {
    $enterUrl = $_SESSION['oringal_user_url'];
}
 
?>
and at the "enter button" it says:

Code: Select all

<div id="yes_button"><a href=<?php print "\"" . $enterUrl . "\""; ?>><img src="http...etc etc

So my question is this. Can I leave the php as it is in the header, and will that mean it will work for all the links, or do I need to modify the code for every new link I put on the splash page? In the back of my mind there must be some way of globally assigning the same thing to each link so I don't need to retype it each time. :banghead:

I hope that makes sense. Like I say, I've been reading every php101 I can find but I am out of my depth, it's taking some time to get my head round this.

Oh I do have WAMP now so I can test locally, but the people I'm redesigning for have not given me access to thier server not any code except for this splash page. Someone else did all the other coding.

Thanks folks.
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: rewriting a splash page; using sessions, changing links

Post by omniuni »

Huh. That's kind of an odd situation. Really, there should be a more universal way to check. Say, a file called "checkauth.php" that is required on each page at the very very top of the code If the user has not identified, it just puts them to the "splash" page. Otherwise, the page just keeps loading. That way, all the pages are protected. Actually, legally speaking, depending on the content, I think you'll have to take an approach like this. After all, if you have to display an 18-and-up splash, then it would be rather bad for someone to be able to get past it by clicking any odd link that Google gives them that's past your splash.

Does that help, or perhaps you can prod me in a better direction to answer your question?
marshpixie
Forum Newbie
Posts: 9
Joined: Sat Jan 09, 2010 6:24 am

Re: rewriting a splash page; using sessions, changing links

Post by marshpixie »

Yes that does help a little. Thank you.

Here's more info. It's not an adult site as such, it's erotic literature that users can buy as e books so there are no images that could be offensive, but potentially the content could be. There is no legal requirement for a warning but the owner wants to be responsible, and so puts up the "if you're not 18 go away" thing.

Now as far as I am concerned, we're making this splash page into the index page in a sense. It's going to be covered in links with dynamically changing images of the book covers and so on, so I don't call it a splash page in the true sense. BUT I've only be asked to redesign this page and teh rest of the site stays as it is, so it's still going to be called splash.php and the "true" index page is inside the site once you've clicked on any link, and once you're in you don't go back to the splash. Personally this is going to be confusing. But the client is king.

And I am a designer not a programmer, hence my sudden crash course in php.

I do not think I can put a file at the top of every page as I am only here to redo the splash page. The owner of the website updates new pages within it, they are using Zen cart and Adobe contribute and having some problems generally, I belive. Yes a complete overhaul is needed...

So. Am I down to basically adding php code to every link on the splash, in the way that there is php code on the current "enter" button? OR can I do it in one nice lovely line of code at the top?

*off to read more "php for complete numpties*
marshpixie
Forum Newbie
Posts: 9
Joined: Sat Jan 09, 2010 6:24 am

Re: rewriting a splash page; using sessions, changing links

Post by marshpixie »

Oh and I ought to say, the reason I am asking here is because all the tutorials I have been reading discuss doing this via a login system, which this site does have but that's on the index page once you've got past the splash. *sigh*
Post Reply