我試圖使用PHP與XAMPP(Apache和MYSQL)做一個簡單的註冊表單。我目前有一個密碼字段的問題,目前顯示它的輸入爲明文,而不是隱藏它從視圖。回顯密碼輸入字段顯示爲文本
?php
$regfields=array("remail"=>"Email","remail2"=>"Re-enter Email","rusername"=>"Username","rpassword"=>"Password","rpassword2"=>"Re-enter Password","rbiz"=>"BizName","rdesc"=>"Desc");
?>
<html>
<body>
<h3>Registration</h3>
<form action="Login.php" name="RegisterForm" method="post" >
<table border="0">
<?php
if(isset($errormsg))
{
echo"$errormsg";
}
foreach($regfields as $field=>$value)
{
if($field!=="rdesc")
{
echo"<tr>";
echo"<td>";
echo"<label for='$field'>$value: </label>";
echo"</td>";
echo"<td>";
echo"<input type='text' name='$field' size='40' maxlength='50' /> </td></tr>";
}
else if($field=="remail"||$field=="remail2")
{
echo"<tr>";
echo"<td>";
echo"<label for='$field'>$value: </label>";
echo"</td>";
echo"<td>";
echo"<input type='text' name='$field' size='40' maxlength='50' /></td></tr>";
}
else if($field=="rpassword"||$field=="rpassword2")
{
echo"<tr>";
echo"<td>";
echo"<label for='$field'>$value: </label>";
echo"</td>";
echo"<td>";
echo"<input type='password' name='$field' size='40' maxlength='50' /></td></tr>";
}
else
{
echo"<tr>";
echo"<td>";
echo"<label for=$field>$value: </label>";
echo"</td>";
echo"<td>";
echo"<input type='text' name='$field' size='300' maxlength='300' style='width:400px;height:100px; \n'/>";
echo"</td>";
echo"</tr>";
}
}
?>
</form>
</table>
<input type="submit" name="Button" value="Register" />
</body>
</html>
我懷疑此行
echo"<input type='password' name='$field' size='40' maxlength='50' /></td></tr>";
其中輸入類型不是由於使用了單引號註冊我的問題,莖,而不是雙引號,導致輸入型從字面上並沒有解釋被用作價值?
我將不勝感激任何輸入。 謝謝!
移除
!
糾正你的代碼是這樣被顯示在輸入爲純文本或提交後..? –您在表格和提交之前關閉表單標記在表單之外。這將如何工作? – Rahul11
嘗試使用'\「字符嘗試轉義此行'echo'