Jump to content

?value On end of link


antonysimpson
 Share

Recommended Posts

not exactly sure what you want. Buit i think
echo $_REQUEST['other'];

should print out the value of other.

in order to print out the value of other shouldnt the url be
<a href="photo-browse.php?other=somevalue">my link</a>

you can also use get

echo $_GET['other'];

Link to comment
Share on other sites

other is the name of the variable but you did not assign a value to it.If you set your link like this.

<a href="photo-browser.php?other=somevalue">Click Me</a>

On photo-browse.php you would get the value like this.

$valueOfOther = $_GET['other'];

$valueOfOther would equal "somevalue"

Link to comment
Share on other sites

Is there a difference between $_GET and $_REQUEST ??I was always told to use $_REQUEST because the server I learned on wouldnt accept anything else.I've never seen $_GET before :) Probably something else my teacher decided to leave out to make me the worst programmer ever.

Link to comment
Share on other sites

Is there a difference between $_GET and $_REQUEST ??I was always told to use $_REQUEST because the server I learned on wouldnt accept anything else.I've never seen $_GET before :) Probably something else my teacher decided to leave out to make me the worst programmer ever.
i think there are suttle differences between them. its like include and require, they do the same thing. its the end result that everyone is looking for. as long as you can get the same result nobody is going to care. there is also $_post but i dont know if you can use that here. that one is used in processing forms. <forum action="myscript.php" method="post"><input type='text' name='name' />... then you use $name = $_post['name']; to get what the user placed in the name input field
Link to comment
Share on other sites

There is $_REQUEST, $_GET, and $_POST$_GET is for getting querystrings from a url and $_POST gets data sent by forms using the post method.Now $_REQUEST checks both so if you had a querystring call x (?x=something) and also a form field submitted called x then $_REQUEST would take the $GET value (i think).but if you used GET and POST you could get both values.$x1 = $_GET['x'];$x2 = $_POST['x'];In some situations using REQUEST can allow attackers to inject attacks through the querystring because REQUEST takes GET first even though you intended it to take POST. All they would have ot do is name a querystirng the same as your form field and could override for intended coding.In some cases this could be very dangerous. I never use request I always use the GET or POST for the exact functionality I want

Link to comment
Share on other sites

basically. If you were on a control panel of some sort and values got passed through form post (hidden value that you normally couldn't access) but they used $_REQUEST to get them. If you were to make a querystring with the same name as the hidden field you could set any value you wanted because REQUEST would use the GET value first.Mind you this is not always a threat only in certain situations and the way you write your code has an effect too, but I have just always avoided using REQUEST so I do not have to worry.

Link to comment
Share on other sites

REQUEST also includes COOKIES, not only GET and POST.
Bah, he beat me. skym knows his stuff.There is a config option in php.ini that defines the order in which the three are checked. Collectively, get, post, and cookie are referred to as gpc. The option sets the gpc order in which to check. By default, cookies override post, and post overrides get. But it is always good practice to use the specific one you are looking for, it makes the code a little more understandable as well.Also, there is a use for having a get variable with no value, like this:page.php?submitif (isset($_GET['submit']))It will be set to an empty string, but it doesn't matter if all you want to know is whether or not it exists.
Link to comment
Share on other sites

Also, there is a use for having a get variable with no value, like this:page.php?submitif (isset($_GET['submit']))It will be set to an empty string, but it doesn't matter if all you want to know is whether or not it exists.
Thanks I never thought of that
Link to comment
Share on other sites

HiyaThanks for the replys. Im trying to create normal links on my-photos.php, like

<a href="photo-browse.php?album=other>Other Photos</a>

And then in photo-browse.php I have the code:

<?php$valueOfalbum = $_GET['album'];echo $valueOfalbum>?

It comes up with an error, whats wrong guys?I eventually want to put an if code together to check the value and then to echo the appropriate photo. With next and previous photos to load them.Antony.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...