Forum Moderators: coopster

Message Too Old, No Replies

I need to be able to grab my value passed using a head location

         

fshaw

1:41 pm on Feb 4, 2008 (gmt 0)

10+ Year Member



I want to use the header location and pass in the string contained in the varable $url the address of the page i want to go to but also i need to pass the value contained in $index which is a string 'historypage1' My problem is what do i do in my index-7.php to handel the value passed. I need to grab the value passed and test it and display it - the real goal after testing the value I am going to use it in a switch statement in PHP tags in my index-7.php web page.

$index = 'historypage1';

$url = "http://www.example.org/index-7.php?lodgeindex='$index'";
ob_end_clean();
header("Location: " . $url);

THANKS

Frank H. Shaw

[edited by: jatar_k at 2:25 pm (utc) on Feb. 4, 2008]
[edit reason] please use example.com [/edit]

d40sithui

5:11 pm on Feb 4, 2008 (gmt 0)

10+ Year Member



to get the variable you passed, you can just use the $_GET or $_REQUEST.

echo $_GET['lodgeindex']; // echo $_REQUEST['lodgeindex'];

keep in mind though, since you have the single quote around the var, it will print out the quotes as well.

fshaw

11:04 pm on Feb 4, 2008 (gmt 0)

10+ Year Member



So it should be this unstead

$index = "historypage1";

$url = "http://www.example.org/index-7.php?lodgeindex='$index'";
ob_end_clean();
header("Location: " . $url);

Is that correct now?

The other thing I would like to understand and address is the security of dong it this way I am using Microsoft windows server using IIS if that makes a difference?

The security of using the $_GET verse the $_REQUEST and what is the impact against hackers.

Is there a better way?

Please explain?

THANKS

Frank H. Shaw

GamingLoft

11:10 pm on Feb 4, 2008 (gmt 0)

10+ Year Member



$index = "historypage1";

$url = "http://www.example.org/index-7.php?lodgeindex=" . $index . "";
ob_end_clean();
header("Location: " . $url);

// Variables must be seperated how i did above. or atleast i believe so..

then to retrive the variable at the url

"http://www.example.org/index-7.php?lodgeindex=historypage1"

you'd use

$index = $_GET['index'];

// pretty easy i think thats what you need? correct?

fshaw

11:51 pm on Feb 4, 2008 (gmt 0)

10+ Year Member



Ok but is this the most secured way to do this or is there a better way i do not want to use a SSL or the HTTPS to handle the passing of the variable.

THANKS

Frank H. Shaw

fshaw

12:08 am on Feb 5, 2008 (gmt 0)

10+ Year Member



Please look at this carefully is the ""; correct after the $index .
why i ask the " " do not seem balenced but where does the missing " go if it os missing that is?

$url = "http://www.example.org/index-7.php?lodgeindex=" . $index . "";

Please explain?

THANKS

Frank h. Shaw

[edited by: coopster at 4:57 pm (utc) on Feb. 5, 2008]
[edit reason] please use example.org [/edit]

GamingLoft

1:14 am on Feb 5, 2008 (gmt 0)

10+ Year Member



you're post got me thinking and i looked at my code again i looked at the quotes and it should be like this...

$index = "historypage1";
$url = "http://www.example.org/index-7.php?lodgeindex="$index;
ob_end_clean();
header("Location: " . $url);

i think that'll do it.. sorry i mess up my quotes all the time and i have hardly a clue what im doing, but i believe you're way in you're 1st post is incorrect, thats just what i see when looking at it.

Sorry to bother you, if you want help see someone more experienced than me, im still newish to php.

K bye.

fshaw

1:44 am on Feb 5, 2008 (gmt 0)

10+ Year Member



Ok I just tried this and it seems to work just fine

$url = "http://www.example.org/index-7.php?lodgeindex=" . $index . ""; // This works just fime
ob_end_clean();
header("Location: " . $url);

In my web page I used the $_GET and it allso was passed as it should.

SO I get to the next part what is the security of passing the varable in this manner.

THANKS

Frank H. Shaw

[edited by: coopster at 4:57 pm (utc) on Feb. 5, 2008]
[edit reason] please use example.org [/edit]

GamingLoft

2:33 am on Feb 5, 2008 (gmt 0)

10+ Year Member



K im not really a genious on this topic but...

1) to me it seems like all you're passing is like a page name right? so whats the point of the security here?

2) If its about security you probably shouldn't use this function, maybe php sessions? etc.

fshaw

2:49 am on Feb 5, 2008 (gmt 0)

10+ Year Member



I have thought about using sessions for passing the varables but i am trying to figure out if i should or not and trying to get a better understanding of of it is the better way to do.

By using $_SESSION how much better is it.

I am not passing the page name but a tag to pass to a PHP logical switch that will actual put the web page stuff in a iframe.

THANKS

Frank H. Shaw

GamingLoft

10:22 pm on Feb 5, 2008 (gmt 0)

10+ Year Member



Well from my knowledge, using sessions makes it so that all the visitors data is kept on the server and is not transfered back and forth from the server to their computer.

Thats the whole security in SESSIONS.

[edited by: GamingLoft at 10:23 pm (utc) on Feb. 5, 2008]