AllExperts > PHP5 
Search      
PHP5
Volunteer
Answers to thousands of questions
 Home · More PHP5 Questions · Answer Library  · Encyclopedia ·
More PHP5 Answers
Question Library

Ask a question about PHP5
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Travis Pessetto
Expertise
Variables, MySQL database,POST, GET, COOKIE

Experience
Self taught

 
   

You are here:  Experts > Computing/Technology > Perl/PHP > PHP5 > How to pass data while redirecting page

PHP5 - How to pass data while redirecting page


Expert: Travis Pessetto - 5/6/2007

Question
QUESTION: Sir,

I want to pass the values (username) while redirecting the page.

I have 3 pages.

1 Login form
2 Login check page (using MYSQL database)
3 home page for registered user.

The Procedure : user fills the form (using post method), check login page checks the user is registered or not, if registered, redirect to the registered user's home page.

Aim : I want to print user name on each page.

Problem :  When check login page checks, user is registered or not, if user is registered the page starts new session and page redirect to registered user's home page but it lost the user name while redirecting the page (using header: location.....),

How can I pass the user name to registered user's home page.


Please help me to sought out my problem.

Thanks.

Ashish"
ANSWER: My advise would be to set a cookie with the user name and then recall it in the script you want by $_COOKIE['name'];  This seems to work for my scripts.

Regards,
Travis Pessetto

---------- FOLLOW-UP ----------

QUESTION: Sir,

There is any other options.

I saw a website (www.shaadi.com)which works fine if user disable cookie.

Regards,

Ashish

ANSWER: You could hold that information in a text file that has the computers IP.  Then get the Text file depending on the users IP return the user name.

Regards,
Travis Pessetto

---------- FOLLOW-UP ----------

QUESTION: Sir,

I don't know about this mathod. Can you provide me some more details (any example if possible).

Thanks in advance.

Regards,

Ashish

Answer
You know what I thought of an easier way to send the values.  You can use the GET command by sending it in the redirection header.  you use it by pointing to your script and putting a ?name=value  for example I want to send name in a script called getname it would look like this http://adomain.com/getname.php?name=Travis this would send Travis to the variable $_GET['name'] so you could do it that way too.

Regards,
Travis Pessetto

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.