A problem with variables?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tuuska

    A problem with variables?

    Hello!

    Please help a newbie in PHP... I have a problem with variables.

    I have a website which has a form. Form asks for an email-address:

    <form action="conf.ph p" method="post">
    email : <input type"text" name="email">
    </form>

    Variable $email works fine in conf.php but what do I have to do to
    make the same $email work in other xxxxxx.php -sites?

    Thanks.

    Tuuska
  • Richard Hockey

    #2
    Re: A problem with variables?


    "Tuuska" <tuuska@telaket ju.net> wrote in message
    news:f7adb5e3.0 308051440.2f46c 371@posting.goo gle.com...[color=blue]
    > Hello!
    >
    > Please help a newbie in PHP... I have a problem with variables.
    >
    > I have a website which has a form. Form asks for an email-address:
    >
    > <form action="conf.ph p" method="post">
    > email : <input type"text" name="email">
    > </form>
    >
    > Variable $email works fine in conf.php but what do I have to do to
    > make the same $email work in other xxxxxx.php -sites?[/color]

    $email will only be defined in the php page specified in the form action
    property, it will not exist in any other php pages on the site, especially
    if the form is submitted via the POST method.

    If you want to transfer the value of $email from the form action page to
    other php pages, you could use session variables, or a database, or an XML
    file to store the value.

    Also you ought to use $_POST["email"] or $HTTP_POST_VARS["email"] when you
    try to read the form variables.

    (use $_GET["email"] for the 'GET' submission method)

    This is a result of the register_global s property in php.ini being set to
    'off' by default since php version 4.3 was introduced. This measure was
    taken to improve the security of php scripts.
    [color=blue]
    >
    > Thanks.
    >
    > Tuuska[/color]


    Comment

    • Nikolai Chuvakhin

      #3
      Re: A problem with variables?

      tuuska@telaketj u.net (Tuuska) wrote in message
      news:<f7adb5e3. 0308051440.2f46 c371@posting.go ogle.com>...[color=blue]
      >
      > I have a website which has a form. Form asks for an email-address:
      >
      > <form action="conf.ph p" method="post">
      > email : <input type"text" name="email">
      > </form>
      >
      > Variable $email works fine in conf.php but what do I have to do to
      > make the same $email work in other xxxxxx.php -sites?[/color]

      Your options are: (1) continue to pass it between pages via GET or
      POST, (2) store it in a session variable, or (3) store it in a cookie.

      Cheers,
      NC

      Comment

      • george

        #4
        Re: A problem with variables?

        by -sites do you mean pages ?

        Put this in your form page, which is php?
        <?PHP
        session_start() ;
        ?>

        Put this in any other page.
        <?PHP
        session_start() ;
        ?>
        <?PHP
        $email2 = $_POST['email'];
        //and you can check if you got it ok
        echo $email2;
        ?>

        Comment

        Working...