By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,614 Members | 1,653 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,614 IT Pros & Developers. It's quick & easy.

A problem with variables?

P: n/a
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.php" 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
Jul 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"Tuuska" <tu****@telaketju.net> wrote in message
news:f7**************************@posting.google.c om...
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.php" 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?
$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_globals 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.

Thanks.

Tuuska

Jul 16 '05 #2

P: n/a
tu****@telaketju.net (Tuuska) wrote in message
news:<f7**************************@posting.google. com>...

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

<form action="conf.php" 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?


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
Jul 16 '05 #3

P: n/a
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;
?>
Jul 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.