PHP Level = beginner
I am trying to write a simple program that displays the number-times of a particular value when placed in the input box. I have tried to use the post method to do this but each time the program is up running and the submit button is selected, it displays the whole code of the php file 'timescalc.php'. I'll like to know what I am doing wrong, although I know that the calculations with the if statements might be wrong.
Heres the code
<DOCTYPE html>
<html>
<head>
<title>Number Times</title>
</head>
<body>
<h1>Number Times Table Calculator</h1>
<form method="post" action="timescalc.php">
Enter Number : <input type="text" name="number"> <br>
<input type="submit" value="submit"/>
</form>
<?php
$number = $_POST['number'];
if ($number == 2, $number ++2)
{
echo $number . ;
}
else if ($number == 3, $number ++3)
{
echo $number . ;
}
else if ($number == 4, $number ++4)
{
echo $number . ;
}
else if ($number == 5, $number ++5)
{
echo $number . ;
}
else
{
echo "pick numbers from 2 to 5 only" ;
}
?>
</body>
</html>
.phpand if you're running this from your computer, making sure PHP is installed and properly configured. 9 times out of 10, that's what it is..phpfiles are not like.htmfiles where the browser properly outputs it. A browser doesn't need a "parser", it's built-in.