Example
<body>
<form id="form1" name="form1" method="post" action="">
<label>ENTER NUMBER::
<input type="text" name="t1" />
</label>
<p> </p>
<p>
<label>
<input type="submit" name="b1" value="Submit" />
</label>
</p>
<p> </p>
<p> </p>
<?php
if(isset($_POST["b1"]))
{
if(is_numeric($_POST["t1"]))
{
if($_POST["t1"]%2==0)
{
echo $_POST["t1"]." IS EVEN";
}
else
{
echo $_POST["t1"]." IS ODD";
}
$i=2;
while($i<$_POST["t1"])
{
if($_POST["t1"]%$i==0)
{
echo "\n"." & It is not Prime Number";
break;
}
$i++;
}
if($i==$_POST["t1"])
{
echo "\n"." & it is Prime Number";
}
}
else
{
echo "INPUT A NUMBER !!";
}
}
?>
</form>
</body>
<body>
<form id="form1" name="form1" method="post" action="">
<label>ENTER NUMBER::
<input type="text" name="t1" />
</label>
<p> </p>
<p>
<label>
<input type="submit" name="b1" value="Submit" />
</label>
</p>
<p> </p>
<p> </p>
<?php
if(isset($_POST["b1"]))
{
if(is_numeric($_POST["t1"]))
{
if($_POST["t1"]%2==0)
{
echo $_POST["t1"]." IS EVEN";
}
else
{
echo $_POST["t1"]." IS ODD";
}
$i=2;
while($i<$_POST["t1"])
{
if($_POST["t1"]%$i==0)
{
echo "\n"." & It is not Prime Number";
break;
}
$i++;
}
if($i==$_POST["t1"])
{
echo "\n"." & it is Prime Number";
}
}
else
{
echo "INPUT A NUMBER !!";
}
}
?>
</form>
</body>
No comments:
Post a Comment