Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

how can i pass variable on a link ?

Posted on 2003-10-27
7
208 Views
Last Modified: 2006-11-17
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.
0
Comment
Question by:kets4u
7 Comments
 
LVL 2

Accepted Solution

by:
errows earned 30 total points
ID: 9626979
Then you should use sessions instead of variables on a link.

See http://www.zend.com/zend/tut/session.php for a session tutorial

or http://www.zend.com/zend/tut/tutorial-delin4.php for an authentication tutorial with cookies... as you wish !
0
 
LVL 7

Expert Comment

by:kohashi
ID: 9632343
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
0
 
LVL 1

Expert Comment

by:lamdor
ID: 9632369
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.
0
 
LVL 2

Expert Comment

by:TaintedGod
ID: 9654298
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.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question