Author Topic: [PHP] Get the URL of the html file that called it  (Read 10029 times)

0 Members and 1 Guest are viewing this topic.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: [PHP] Get the URL of the html file that called it
« Reply #15 on: September 12, 2011, 06:48:48 am »
There's 1 real secure way to do this.
As soon as the form is loaded (for example: ./form.php)
You create a $_SESSION['currentpage'] = 'form.php';

And when the user submits the form, you check that variable. If it's empty, the user has deleted the session cookie.
In that case you simply return back to the form ;)

Er, what? I only need to get the location of the form, like:

http://www.mywebsite.com/folder/form.html

The location is http://www.mywebsite.com/folder.

Offline Ikkerens

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 378
  • Rating: +28/-9
  • JavaScript Magician
    • View Profile
    • Walotech
Re: [PHP] Get the URL of the html file that called it
« Reply #16 on: September 12, 2011, 06:53:10 am »

Er, what? I only need to get the location of the form, like:

http://www.mywebsite.com/folder/form.html

The location is http://www.mywebsite.com/folder.

Well, then, first, i'd change form.html to form.php then
On top of form.php you add:
Code: (php) [Select]
<?php

session_start
();
$_SESSION[&#39;location&#39;] = &#39;http://www.mywebsite.com/folder&#39;;

?>


And on handler.php (the form action):
Code: (php) [Select]
<?php

session_start
();

if ( !isset(
$_SESSION[&#39;location&#39;]) )
{
   die(&
#39;OMFGZ, Y U DELETE COOKIE? <a href="#" onClick="javascript:history.back();">Go back</a>&#39;);
}

var 
$loc $_SESSION[&#39;location&#39;];

if ( $loc == &#39;http://www.mywebsite.com/folder&#39; )
{
   
//Specific functions for this location
}

?>

« Last Edit: September 12, 2011, 06:53:59 am by Ikkerens »

Splut for Android [----------]
Paused/halted indefinitely, might be abandoned, our graphic designer quit and the rest of us simply doesn't have the time to work on it...

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: [PHP] Get the URL of the html file that called it
« Reply #17 on: September 12, 2011, 06:54:16 am »
Ikkerens, you are not understanding... I don't know what the URL is, "http://www.mywebsite.com/folder" was an example. I need to get it as I said before ;)

Offline Ikkerens

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 378
  • Rating: +28/-9
  • JavaScript Magician
    • View Profile
    • Walotech
Re: [PHP] Get the URL of the html file that called it
« Reply #18 on: September 12, 2011, 06:58:53 am »
But you said you were already using a string to set the location.
Well, my solution ain't dynamic either, but at least more secure than that imho

Splut for Android [----------]
Paused/halted indefinitely, might be abandoned, our graphic designer quit and the rest of us simply doesn't have the time to work on it...

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: [PHP] Get the URL of the html file that called it
« Reply #19 on: September 12, 2011, 07:00:51 am »
But you said you were already using a string to set the location.
Well, my solution ain't dynamic either, but at least more secure than that imho

I have a string with it, in the php file, there's no way the user can delete it.

Offline Ikkerens

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 378
  • Rating: +28/-9
  • JavaScript Magician
    • View Profile
    • Walotech
Re: [PHP] Get the URL of the html file that called it
« Reply #20 on: September 12, 2011, 07:01:57 am »
Nevermind then :P

Splut for Android [----------]
Paused/halted indefinitely, might be abandoned, our graphic designer quit and the rest of us simply doesn't have the time to work on it...

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: [PHP] Get the URL of the html file that called it
« Reply #21 on: September 12, 2011, 09:58:09 am »
Nevermind then :P

No problem, thanks for the attention ;)