2016-12-03 5 views
0

2つの偶数の間に奇数を見つけようとする推測機械ですが、それは動作しません。何が間違っていますか?PHPの&html推測機。これはコードですが、おそらく間違っていますか?

<?php 
$num_to_guess = 17; 
if(!isset(($_POST['guess']) && ($_POST['guess1']))){ 
$message="Try to guess an odd number by entering the two even numbers directly before and after it";} 
elseif (($_POST['guess'] < $num_to_guess) && ($_POST['guess1'] > $num_to_guess)){ 
$message="You guessed the odd number 17";} 
elseif (($_POST['guess'] < $num_to_guess) && ($_POST['guess1'] <$num_to_guess)){ 
$message="Both numbers you entered are smaller than the odd number";} 
elseif (($_POST['guess'] > $num_to_guess) && ($_POST ['guess1'] > $num_to_guess)){ 
$message="Both numbers you entered are larger than the odd number";} 
elseif (($_POST['guess']%2!=0) && ($_POST['guess1']%2!=0)){ 
$message="Please enter even numbers only";}  
?> 


<html> 
<head> 
<title>A PHP number guessing script</title> 
</head> 
<body> 
<h1><?php echo $message; ?></h1> 
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> 
<p><label for="guess">Welcome! Enter your new guesses:</label><br/> 
<input type="text" is="guess" name="guess" /> 
<input type="text" is="guess1" name="guess1"/></p> 
<button type="guess" name="guess" value="guess">guess</button> 
</form> 
</body> 
</html> 

答えて

0

あなたはisset()で条件を定義していますが間違っています。 '& &'の代わりに '、'(コンマ記号)を使用します。すなわち

if(!isset($_POST['guess'], $_POST['guess1'])){ 
    // your code here 
} 
関連する問題