kingot
01-20-2012, 11:08 AM
Hi,
I have this code here using oop in php .Now i want the user to enter prime numbers specified in $this->prime..but the code is not working..Here is the code
<?php
class Prime{
public $prime;
public function CheckPrime(){
if(isset($_POST['prime']) && !empty($_POST['prime'])){
$this->prime=$_POST['prime'];
if(preg_match('/^[0-9]+$/', $this->prime)){
if($this->prime==Array(1,3,5,7,9,11,13,15,17,199,21,23,25,27,29,31)){
echo 'Ok';
}
}else{
echo 'Please enter numbers only';
}
}else{
echo 'Please enter a prime number ranging from 1-31 to test the programe';
}
}
}
$PrimeCheck= new Prime;
$PrimeCheck->CheckPrime();
?>
<form action="index.php" method="POST">
Enter a Prime number: <input type="text" name="prime"><input type="submit" value="Submit">
</form>
Thanks
Clement Osei
I have this code here using oop in php .Now i want the user to enter prime numbers specified in $this->prime..but the code is not working..Here is the code
<?php
class Prime{
public $prime;
public function CheckPrime(){
if(isset($_POST['prime']) && !empty($_POST['prime'])){
$this->prime=$_POST['prime'];
if(preg_match('/^[0-9]+$/', $this->prime)){
if($this->prime==Array(1,3,5,7,9,11,13,15,17,199,21,23,25,27,29,31)){
echo 'Ok';
}
}else{
echo 'Please enter numbers only';
}
}else{
echo 'Please enter a prime number ranging from 1-31 to test the programe';
}
}
}
$PrimeCheck= new Prime;
$PrimeCheck->CheckPrime();
?>
<form action="index.php" method="POST">
Enter a Prime number: <input type="text" name="prime"><input type="submit" value="Submit">
</form>
Thanks
Clement Osei