Professional Web Applications Themes

passing variables between php pages - PHP Development

If I have a php page that uses the header function to load a second php page, how can I access variables defined in the first php page without passing them via the url?...

  1. #1

    Default passing variables between php pages

    If I have a php page that uses the header function to load a second php
    page, how can I access variables defined in the first php page without
    passing them via the url?
    Hendry Guest

  2. #2

    Default passing variables between php pages

    if i have a.php and I define some variables, and I want to access these
    variables from b.php but do not want to pass them via the url what
    options do i have?

    I am guessing 2 cookies or oject orientation useing classes?
    Hendry Guest

  3. #3

    Default Re: passing variables between php pages

    On Mon, 13 Jun 2005 21:01:00 +0000 (UTC), Hendry Taylor
    <com> wrote:
     

    Cookies.
    Sessions.

    --
    Andy Hassall / <co.uk> / <http://www.andyh.co.uk>
    <http://www.andyhsoftware.co.uk/space> Space: disk usage ysis tool
    Andy Guest

  4. #4

    Default Re: passing variables between php pages


    The best method would be to have b.php include a.php using the includ
    or require function.

    This makes a.php part of b.php and then you can access the variables a
    if they were defined in b.php

    --
    Gnom

    "Your computer has too much computer in it, and not enough typewriter."

    gcs/it$ d- s+: a--? c++ u* !p l++ e---- w+++ !n o? !k-? !w o? m++ v
    !ps !pe y+ pgp t++ !5 x+ r+ tv+ b+ di+ d- g+ e(++) h* r+++ y
    -----------------------------------------------------------------------
    Gnomo's Profile: http://www.macosx.com/forums/member.php?userid=938
    View this thread: http://www.macosx.com/forums/showthread.php?t=22466
    macosx.com - The Answer to Mac Support - http://www.macosx.co

    Gnomo Guest

  5. #5

    Default Re: passing variables between php pages

    I looked up Sessions in PHP fasts&easy web development and they looked pretty hard on the surface. Can you expanded on their usage a little?

    Thanks,
    Lee

    "Andy Hassall" <co.uk> wrote in message news:com... 
    >
    > Cookies.
    > Sessions.
    >
    > --
    > Andy Hassall / <co.uk> / <http://www.andyh.co.uk>
    > <http://www.andyhsoftware.co.uk/space> Space: disk usage ysis tool[/ref]
    Lee Guest

  6. #6

    Default Re: passing variables between php pages

    Lee David wrote:
     

    Did you try the manual? There's explainations there, examples and a lot
    of user contributed notes.

    http://www.php.net/manual/en/ref.session.php

    --
    Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
    Chris Guest

  7. #7

    Default Re: passing variables between php pages

    If those variables should be able to change in time, you could try using
    sessions.

    Hendry Taylor wrote:
     

    Denis Guest

  8. #8

    Default Re: passing variables between php pages

    On Mon, 13 Jun 2005 20:32:00 -0500, "Lee David"
    <net> wrote:
     

    There's not much to them, at least for basic usage.

    You call session_start() on every page.

    You set a value in $_SESSION on one page.

    The same value is then available on the next page.

    http://php.net/session

    --
    Andy Hassall / <co.uk> / <http://www.andyh.co.uk>
    <http://www.andyhsoftware.co.uk/space> Space: disk usage ysis tool
    Andy Guest

  9. #9

    Default Re: passing variables between php pages

    It depends on how you're going to be accessing the files. a simple
    include() might do, or you can just have your links to the toher file
    include the variable:
    <a href='b.php?var=<?php echo($var); ?>'>Link</a>
    if those methods wont work, then you can use cookies and sessions.

    Hendry Taylor wrote: 
    Exyle Guest

Similar Threads

  1. help passing url variables...
    By matt57017 in forum Macromedia ColdFusion
    Replies: 6
    Last Post: September 14th, 02:08 AM
  2. Replies: 3
    Last Post: November 14th, 08:16 PM
  3. passing variables to subsequent pages
    By Robb in forum PHP Development
    Replies: 4
    Last Post: November 2nd, 11:04 PM
  4. passing variables between pages
    By Matthew in forum PHP Development
    Replies: 11
    Last Post: October 14th, 04:29 PM
  5. [PHP] Passing variables between pages
    By Jay in forum PHP Development
    Replies: 2
    Last Post: October 14th, 04:18 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139