What is wrong here?


#1

[php]

x = <?php echo "$number"; ?>

<?php // If the submit button has been clicked if (isset($_POST['multiply'])) { // Put the POSTed numbers into variables so we can easily work with them $firstnumber = $_POST['first_number']; $secondnumber = $_POST['second_number']; $number = $firstnumber * $secondnumber; } ?> [/php]

The above code does not display anything from the code: <?php echo "$number"; ?>

Why is that? What is wrong? Thank you in advance!


#2

You need to move your php code where you calculate $number above the html form.


#3

Just needs to be above the html.


#4
hello Addeman, you have to did two changes 1. place your php code above the tag. but if you do not want than it's ok. 2. you are missing ; in action attribute of form. replace action="<?=$_SERVER['PHP_SELF']?>" with below code action="<?=$_SERVER['PHP_SELF'];?>"

other than this everything is fine.
SR


#5

If he wants the variable to show up when he hits submit, then the php has to be on top of the page, or at least above the form.