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

nusphere phped: variable post

P: n/a
Hello,
I'm using nusphere phped to develop php files. I have written
to files named a.php and b.php.

a.php:
------
<html>
<body>
please enter two numbers in the form.<br>
<form action = "b.php" method = "post">
Wert 1: <input name = "w1"><p>
Wert 2: <input name = "w2"><p>
<input type = "submit">
<input type = "reset">
</form>
</body>
</html>

b.php:
------
<html>
<body>
<?php

$erg = $w1 + $w2;
echo "sum: $erg";
?>
</body>
</html>

If I enter numbers in the form, the result (erg) is always 0.
Is it possible that the post method doesnt't work (I have the feeling that
w1 and w2 are local variables)?
Do I have to change settings in Nuspere phped?

Thanks a lot,
Mike
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I noticed that Message-ID:
<b2**************************@posting.google.com > from mi******@gmx.de
contained the following:
If I enter numbers in the form, the result (erg) is always 0.
Is it possible that the post method doesnt't work (I have the feeling that
w1 and w2 are local variables)?
Do I have to change settings in Nuspere phped?


Nope. Do this:

$erg = $_POST['w1'] + $_POST['w2'];
echo "sum: $erg";

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2

P: n/a
Geoff Berrow wrote:
I noticed that Message-ID:
<b2**************************@posting.google.com > from mi******@gmx.de
contained the following:

If I enter numbers in the form, the result (erg) is always 0.
Is it possible that the post method doesnt't work (I have the feeling that
w1 and w2 are local variables)?
Do I have to change settings in Nuspere phped?

Nope. Do this:

$erg = $_POST['w1'] + $_POST['w2'];
echo "sum: $erg";


In order to make sure I get all of the variables, I use something like
this at the beginning of my scripts:
<?php
if (!empty($_GET))
{
extract($_GET);
}
else if (!empty($HTTP_GET_VARS))
{
extract($HTTP_GET_VARS);
}
if (!empty($_POST))
{
extract($_POST);
}
else if (!empty($HTTP_POST_VARS))
{
extract($HTTP_POST_VARS);
}

-- yes it is overkill, but everything works all the time now... :)

Michael Austin.
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.