Forum Moderators: coopster

Message Too Old, No Replies

index.php?example

         

paseo

8:07 pm on Feb 9, 2007 (gmt 0)

10+ Year Member



I am trying to setup a way so that variables passed via the url are actually set as a variable. Ex..

[abc.com...]

the "rid" is the variable that i want populated with the value of 1

$rid = 1

so that it may be used in :

$result=mysql_query("select firstname from $table where id=$rid");

cameraman

8:17 pm on Feb 9, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$rid = $_GET['rid'];

You should always make sure the variables are as you expect, so for an integer like that, this is better:
$rid = intval($_GET['rid']);

And when possible, make sure it's in the range you expect, etc. before using.

ericjust

8:18 pm on Feb 9, 2007 (gmt 0)

10+ Year Member



All variables passed through the URL are accessible through $_GET.

$rid = $_GET['rid'];

You will DEFINITELY want to escape your variables before passing them into a query.

see
[us2.php.net...]
[us2.php.net...]

paseo

8:23 pm on Feb 9, 2007 (gmt 0)

10+ Year Member



$id= mysql_real_escape_string($_GET['id']);

worked great. Thanks!