6 Replies - 1964 Views - Last Post: 20 May 2012 - 06:03 AM Rate Topic: -----

#1 jx2012   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 19-May 12

Passing variables from one page to the next pages

Posted 19 May 2012 - 07:34 PM

Hi there,

I have a simple question: how to pass variables from one page to the next pages? For example:

I created a page url like this: http://mywebsite.com...t.php?name=John
There are some hyperlinks on this page. I want to automatically add variable "?name=John" to all these hyperlinks. something like: http://test1.com/index.html?name=John http://test2.com/index.html?name=John

How to do it? or how to keep $_GET[name] working on all these hyperlink pages :winkiss: ?

Thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: Passing variables from one page to the next pages

#2 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6642
  • View blog
  • Posts: 30,931
  • Joined: 10-May 07

Re: Passing variables from one page to the next pages

Posted 19 May 2012 - 07:43 PM

Use either the GET or POST array.
Was This Post Helpful? 0
  • +
  • -

#3 jx2012   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 19-May 12

Re: Passing variables from one page to the next pages

Posted 19 May 2012 - 08:01 PM

Thanks. Is there any easy way to do this?
Was This Post Helpful? 0
  • +
  • -

#4 CTphpnwb   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3795
  • View blog
  • Posts: 13,738
  • Joined: 08-August 08

Re: Passing variables from one page to the next pages

Posted 19 May 2012 - 08:04 PM

http://www.php.net/m...build-query.php
Was This Post Helpful? 0
  • +
  • -

#5 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6642
  • View blog
  • Posts: 30,931
  • Joined: 10-May 07

Re: Passing variables from one page to the next pages

Posted 19 May 2012 - 08:19 PM

View Postjx2012, on 19 May 2012 - 11:01 PM, said:

Thanks. Is there any easy way to do this?

Examples are giving in the link I provided.

I see. I misread the question.

You can either use a hidden variable, or session variables.
Was This Post Helpful? 0
  • +
  • -

#6 hiddenghost   User is offline

  • D.I.C Addict
  • member icon

Reputation: 39
  • View blog
  • Posts: 621
  • Joined: 15-December 09

Re: Passing variables from one page to the next pages

Posted 19 May 2012 - 08:35 PM

I really depends on what you mean.

You can use the http_build_query function, or some of the other stuff no2pencil posted.

Or you can just make strings that become links.

$name = 'John';
$url = 'yoursite.com/index.php?name='.$name;

This post has been edited by hiddenghost: 19 May 2012 - 08:37 PM

Was This Post Helpful? 0
  • +
  • -

#7 jx2012   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 19-May 12

Re: Passing variables from one page to the next pages

Posted 20 May 2012 - 06:03 AM

You can use the http_build_query function, or some of the other stuff no2pencil posted.

Or you can just make strings that become links.

1 $name = 'John';
2 $url = 'yoursite.com/index.php?name='.$name;

++++++++++++++++++++++++

Man you guys are awesome. The code above is a piece of good suggestion and it works for my purpose. Thanks a million :D !
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1