Variable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • java.inet@gmail.com

    Variable

    dis is appu

    plz help me

    How to call the one php file variable to another php file........

  • Floortje

    #2
    Re: Variable

    java.inet@gmail .com schreef:
    dis is appu
    >
    plz help me
    >
    How to call the one php file variable to another php file........
    >
    /* This example assumes that someserver is configured to parse .php
    * files and not .txt files. Also, 'works' here means that the variables
    * $varone and $vartwo are available within the include()ed file. */

    /* Won't work; file.txt wasn't handled by someserver. */
    include ("http://someserver/file.txt?varone =1&vartwo=2");

    /* Won't work; looks for a file named 'file.php?varon e=1&vartwo=2'
    * on the local filesystem. */
    include ("file.php?varo ne=1&vartwo=2") ;

    /* Works. */
    include ("http://someserver/file.php?varone =1&vartwo=2");

    $varone = 1;
    $vartwo = 2;
    include ("file.txt") ; /* Works. */
    include ("file.php") ; /* Works. */

    --
    Arjen
    HondenPage: alles over uw hond of honden,fokkers en puppy's. Je vindt hier het hondenforum, honden foto's, fokkers, puppy's, de honden encyclopedie en nog veel meer !

    Comment

    • Schraalhans Keukenmeester

      #3
      Re: Variable

      At Tue, 15 May 2007 01:42:02 -0700, java.inet let his monkeys type:
      dis is appu
      >
      plz help me
      >
      How to call the one php file variable to another php file........
      Arjen just gave you a solution for when you want to include a file in
      another with variables parsed to it. If what you want is variables
      keeping their values after (e.g.) clicking a link on the first page, which
      opens a second...

      You can do it the unsafe & dirty way:

      (PS I left out all the proper html tags that a page should have)

      <?PHP
      //script 1
      $myvar = "Hello World!";
      $_GET['myvar'] = $myvar;
      // or $_POST['myvar'] = $myvar;
      ?>
      <a href='script2.p hp'>Click!</a>

      or

      <?PHP
      //script 1
      $myvar = "Hello World!";
      echo "<a href='script2.p hp?myvar=$myvar '>Click!</a>";
      ?>


      <?PHP
      //script 2
      echo $_REQUEST['myvar'];
      // or $_GET/$_POST, whichever you used
      ?>

      Or you do it the safe and sound way:

      <?PHP
      //script 1
      session_start() ;
      $myvar="Hello Safe World!";
      $_SESSION['myvar'] = $myvar;
      ?>
      <a href='script2.p hp'>Click!</a>

      <?PHP
      //script 2
      session_start() ;
      if (isset($_SESSIO N['myvar']) {
      $myvar = $_SESSION['myvar'];
      echo $myvar;
      }
      session_destroy ();
      unset($_SESSION );
      ?>

      The former method is vulnerable to attacks. Anyone calling the script like
      so:


      might mess up your program.

      There's also the possibility to use forms with hidden fields to get
      variables across, this basically sets $_GET or $_POST avriables similar to
      the first example.

      HTH

      Sh.

      Comment

      • Jerry Stuckle

        #4
        Re: Variable

        java.inet@gmail .com wrote:
        dis is appu
        >
        plz help me
        >
        How to call the one php file variable to another php file........
        >
        Do you mean within the same web page, or on a new web page? If the
        latter, you need to use sessions.

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        Working...