Php Script To Display Prime Numbers

 




(Primeno.html)

<!DOCTYPE html>
<html>
<form method="POST" action="prime.php">
Enter No:<input type="number" name="n1"><br>
<input type="submit">
</form>
</html>

(prime.php)

<?php 
$n=$_POST["n1"];
$count=0;
for($i=1;$i<=$n;$i++) {
   if($n%$i==0) {
     $count++;
    }
}
if($count==2)
echo "Its prime Number";
else
echo "its not prime number";
?>

Embed this Php File so that html form can have its function of identifying Prime Number.
 
Output











Comments