2013-07-18 40 views
-5

我的PHP沒有正確響應,這裏是我的HTML代碼我的代碼沒有響應,因爲我希望它是?

<html> 
<body> 
<form name="myform" method="post" action="lol.php"> 
<input type="text" name="man" value=""> 
<input type="submit" name="submit" value= "post"> 
</form> 
</body> 
</html> 

這是我的PHP代碼

<?php 

if ($_POST['man']= null) 
{print ('has no value');} 
else {print ($_POST['man']); 
} 
?> 
+4

它是如何響應? – 4444

+3

你想如何迴應? – 3ventic

+0

它沒有給出if和else的答案 –

回答

7

使用==運營商進行比較,而不是=,因爲第二個是用於分配。

if ($_POST['man']== null) 
{ 
print ('has no value');} 
else { 
print ($_POST['man']); 
} 

PHP Comparison Operators

3

變化

if ($_POST['man']= null) 

if ($_POST['man'] == null) 
0

您收到任何錯誤?

嘗試:

if (isset($_POST['man'])) { 
    echo $_POST['man']; 
} 
else { 
    echo 'Nothing'; 
} 

,並確認一切正常使用這樣的:

var_dump($_POST); 

的你會看到$_POST

0

起初的值,你應該使用isset來代替=,第二個也很重要:=是一個賦值,但是你想要的是一個比較,所以使用==並且與一個空字符串比較

相關問題