Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a php page that will ask the user to enter a number on a text box and then

ID: 3548640 • Letter: W

Question

Write a php page that will ask the user to enter a number on a text box and then output a

message to indicate if the number is even or odd

Modify the above, in addition to output if the number is even or odd, output if the number is a

prime number.

i have this code for even or odd. but i need it to be able to ask the user to enter the number in textbox. can you help me with the code i currently have to get this working!


Even or odd:

$number = 20;

if ($number % 2 == 0) {

print "It's even";

}



PRIME:

function isPrime($num) {

//1 is not prime. See: http://en.wikipedia.org/wiki/Prime_number#Primality_of_one

if($num == 1)

return false;


if($num == 2)

return true;


if($num % 2 == 0) {

return false;

}


for($i = 3; $i <= ceil(sqrt($num)); $i = $i + 2) {

if($num % $i == 0)

return false;

}


return true;

}

Explanation / Answer

Input file

<?php>

echo "Enter a number: <input type="number" name="number">";

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote