Link to home
Start Free TrialLog in
Avatar of kets4u
kets4u

asked on

how can i pass variable on a link ?

hi,
i have one links, from that user can access one of secure page...
but i want to check first, if user is already logged in, then only he can access page otherwise, he directly go to login.php from that links.
ASKER CERTIFIED SOLUTION
Avatar of errows
errows

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
link:
<a href="file.php?var1=data1&var2=data2&var3=data3">link stuff</a>

data retrieval:
$var1=$_GET["var1"];
$var2=$_GET["var2"];
$var3=$_GET["var3"];


You can add as many as you like, just keep adding a & sign in the link with 'variable name' = 'data'.

To retrieve it, you just use the $_GET environmental variable.

You can then work with those variables however you like... compare them against a database or something hard coded into the PHP file to authenticate.

hope that helps,
-kohashi
Avatar of lamdor
lamdor

Hi kohashi,

 I think we can't pass with URL more than 256K of data..
' don't say as many as he wants'..

 The above one works fine..

with regards
lam.
I dont know about you but, its pretty hard to make a url with 256k worth of data, by hard i mean, you would never end up storing that much in an address bar.

But i think sessions is a better idea if you are worried about security.