Forum Moderators: coopster

Message Too Old, No Replies

Another newbie question :)

         

astinov

11:14 pm on Jan 13, 2005 (gmt 0)

10+ Year Member



Hey guys, Thanks for the help in advance:

As I said in my previous post I'm very new to PHP, so please bare with my newbie question and thanx for any and all help.

Well, I'm just testing the waters right now and I'm trying to make a simple html page that will ask for two numbers and after the data is submited calculate the result and print it. Everything works, but there are two annoying notices that I can't get rid of. Here it is in detail, it's really simple:

The HTML Form file:

------------------------------------------
<html>
<head>
<title>Simple adding</title>
</head>

<body>
<form method="post" action="add.php">
<input name="number1" type="text" size="10">
<input name="number2" type="text" size="10">
<input type="submit" value="Add Numbers">
</form>
</body>
</html>
----------------------------------------

The php file with the calculation script:

----------------------------------------

<?
$result = $_POST[number1] + $_POST[number2];
?>
<html>
<head>
<title></title>
</head>
<body>
<p> The Result is <? echo "$result";?>
</body>
</html>

--------------------------------

Upon execution of the above I AM getting the right output but in addition I get this:

Notice: Use of undefined constant number1 - assumed 'number1' in .....wherever and

Notice: Use of undefined constant number2 - assumed 'number2' in ..... wherever

Why am I getting this, even though my result is being displayed properly (e.g. if i input 5 and 5 i'll get 10)

Thanks!

Astinov

dkin

11:16 pm on Jan 13, 2005 (gmt 0)

10+ Year Member



<?
$result = $_POST['number1'] + $_POST['number2'];
?>
<html>
<head>
<title></title>
</head>
<body>
<p> The Result is <? echo "$result";?>
</body>
</html>

enter that for your calculation script and all is well.

astinov

11:18 pm on Jan 13, 2005 (gmt 0)

10+ Year Member



LOL...

Thank you ...

darn syntax errors they always plague me!
LOL
thanks

[edited by: jatar_k at 11:22 pm (utc) on Jan. 13, 2005]
[edit reason] language [/edit]