Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1075929 Posts in 44152 Topics- by 36120 Members - Latest Member: Royalhandstudios

December 29, 2014, 03:58:59 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Make page inaccessible from URL
Pages: [1]
Print
Author Topic: Make page inaccessible from URL  (Read 3563 times)
kamac
Level 10
*****


Notorious posts editor


View Profile Email
« on: May 02, 2013, 07:47:05 AM »

Hey there.

I am asking here because I couldn't form the right question for google..
Basically: I want to have an image in my site and if user clicks it, I want to redirect him to a new page, only that this new page will have the same URL address. I want it to be accessible only by clicking that button, on that page.

Is it possible? (I guess I could use PHP / javascript ?)
Logged

Nothing to do here
Maud'Dib Atreides
Level 4
****


Obsessed with space


View Profile WWW Email
« Reply #1 on: May 02, 2013, 08:25:06 AM »

Interesting question, kamac.

From your question I'm imagining that you should keep your content from both pages on one single page, then use some form of preprocessing verification (Hypertext Preprocessor? Wink ) That checks a session variable or cookie on whether to print the first page's content (AKA the image that you want to be clicked) or the second page's content (Which includes the destination that you will get to after clicking it)

That's the way that I would tackle it, you could do the cookies with Javascript and the verification within PHP, but ultimately you would need both to be on the same page (In the same .PHP file preferably, but the PHP code is what determines what version of the page is printed, from reading in the cookie)


EDIT: (Rethinking this, if you use this method, give the cookie an extremely short lifespan with a timely expiration date)
Logged

Guy: Give me all of your money.
Chap: You can't talk to me that way, I'M BRITISH!
Guy: Well, You can't talk to me that way, I'm brutish.
Chap: Somebody help me, I'm about to lose 300 pounds!
Guy: Why's that a bad thing?
Chap: I'M BRITISH.
kamac
Level 10
*****


Notorious posts editor


View Profile Email
« Reply #2 on: May 02, 2013, 08:41:42 AM »

Interesting question, kamac.

From your question I'm imagining that you should keep your content from both pages on one single page, then use some form of preprocessing verification (Hypertext Preprocessor? Wink ) That checks a session variable or cookie on whether to print the first page's content (AKA the image that you want to be clicked) or the second page's content (Which includes the destination that you will get to after clicking it)

That's the way that I would tackle it, you could do the cookies with Javascript and the verification within PHP, but ultimately you would need both to be on the same page (In the same .PHP file preferably, but the PHP code is what determines what version of the page is printed, from reading in the cookie)


EDIT: (Rethinking this, if you use this method, give the cookie an extremely short lifespan with a timely expiration date)

Seems to be a good option, I'll try that. Wink
Logged

Nothing to do here
CowBoyDan
Level 3
***


View Profile WWW
« Reply #3 on: May 02, 2013, 08:47:18 AM »

have the button be on a form that post to a url that is the same as the original url, have the post method return the "hidden" page.
Logged
biomechanic
Level 3
***


View Profile
« Reply #4 on: May 02, 2013, 01:02:21 PM »

If you need to actually make a redirect, CowBoyDan's suggestion would be the simplest.

If you just want to switch the displayed content, you could add a hidden container (display:none) to the page with the image, and on image click hide the original content / show the other stuff.
Logged
kamac
Level 10
*****


Notorious posts editor


View Profile Email
« Reply #5 on: May 05, 2013, 08:27:15 AM »

One more question:
Can bots get to my "secret" page, if it has one button on it ( under somePage.php ), that looks like this:

Code:
<a href="#" name="button"><div class="button"></div></a>

I've got this jQuery code for handling that:

Code:
$("a[name=button]").click(function(e) {
    e.preventDefault();
    $.cookie("pressed","1",{ path: "/" });
    window.location.reload();
});

After page reloads, PHP code checks which "version" of the page to display.

It looks like that:

Code:
if($_COOKIE["pressed"] == 0)
    include("pages/ie8aw9g0aw9a0240209awmd224/normal.php");
else
    include("pages/ie8aw9g0aw9a0240209awmd224/secret.php");

Now the question is, can some bot access that page and use it to spam my e-mail form?
Should I add some form of captcha?
Logged

Nothing to do here
Jubjub
Level 1
*



View Profile
« Reply #6 on: May 05, 2013, 08:39:21 AM »

Well, one could make a bot that sent that particular cookie and spam your contact form, but I wouldn't worry about generic spambots, since they don't go around pressing javascript buttons and hoping that a contact form pops up.
Logged
biomechanic
Level 3
***


View Profile
« Reply #7 on: May 05, 2013, 09:03:36 AM »

Code:
<a href="#" name="button"><div class="button"></div></a>
Unless you're using HTML5, don't put block-level elements inside inline elements.
Logged
kamac
Level 10
*****


Notorious posts editor


View Profile Email
« Reply #8 on: May 05, 2013, 09:09:06 AM »

Code:
<a href="#" name="button"><div class="button"></div></a>
Unless you're using HTML5, don't put block-level elements inside inline elements.

I intend to use HTML5.

Code:
<!DOCTYPE html>
<html>

I guess that makes me? Giggle


Quote
Well, one could make a bot that sent that particular cookie and spam your contact form, but I wouldn't worry about generic spambots, since they don't go around pressing javascript buttons and hoping that a contact form pops up.

Cool, thanks. I guess that if somebody really wants to spam my mail, he can do that with normal mailing too.. I only wondered if random bots could access it.
Logged

Nothing to do here
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic