爲什麼這不起作用,或者我只是很愚蠢?它不顯示任何信息,頁面看起來後,我按一下按鈕完全一樣(我在我的實際代碼的<form>
和一切)選擇了單選按鈕PHP
<html>
<input type="radio" name = "gender" value = "male">
<input type="radio" name = "gender" value = "female">
<input type="radio" name = "race" value = "asian">
<?php
if(isset($_POST["Button"]))
{
if(($_POST["gender"] == "male") && ($_POST["race"] == "asian"))
{
echo "you are male and asian";
}
}
?>
</html>
整個地區與之相關的代碼如下所示:
<html>
<center>
<body>
<form method=post action= "">
<br>
<br>
Name: <input type="text" name="username">
<br>
<br>
<br>
I am:
<br>
<br>
<input type="radio" name = "gender" value = "male"> Male
<input type="radio" name = "gender" value = "female"> Female
<br>
<br>
</form>
<form method=post action= "">
Ethnicity:
<br>
<br>
<input type="radio" name = "race" value = "asian">Asian
<br>
<br>
<input type="radio" name = "race" value = "black">Black
<br>
<br>
<input type="radio" name = "race" value = "white">White
<br>
<br>
<br>
<input type="submit" name="Button" value = "Who will I marry?">
</form>
<?php
if(isset($_POST["Button"]))
{
if(($_POST["gender"] == "male") && ($_POST["race"] == "asian"))
{
?>
congrats!
<?
}
}
?>
</center>
</body>
</html>
發佈實際的代碼。 – Musa
你可以請出示表格標籤。我想你正在使用'GET'方法。 –
爲什麼你使用兩種形式? –