Lewis Seddon Lewis Seddon - 8 months ago 37
HTML Question

POST with forms is not showing results

The PHP of my code works as I have tested it within a PHP checker online but when trying to run the page online, after clicking the button to submit the number the page does not display anything. Any idea?

$number = ($_POST['number']);
for($i=1;$i<($number+1); $i++){
if (($i % 3 == 0) && ($i % 7 == 0)){
echo "Hello World";
else if (($i % 3 == 0) && ($i % 7 != 0)){
echo "Hello";
else if (($i % 7 == 0) && ($i % 3 != 0)){
echo "World";
echo $i;
print "\n";

<form method="post">
<label for="number">Enter your number here:</label>
<input type="text" id="number" name="number" required>

<button type="submit" name="btn-submit_number">Submit</button>



"after clicking submit" - Did you enter a number in there at all, or a string? Again, I can't see this failing. Is PHP available on the server you're wanting to use? I've seen some (free) servers that don't let you use PHP. If you're using this on your own machine, how are you accessing this as; http://localhost or as file:///? Question's unclear. what browser are you using? – Fred -ii-

@Fred-ii- apologies for the unclear question, I am accessing it via file:/// should I be using localhost? – Lewis Seddon 19 secs ago

There you go. Yes, you need to use http://localhost and not file:///.

PHP isn't being parsed and make sure you have a webserver and PHP installed.