我正在尝试使用带有 XAMPP(Apache 和 MYSQL)的 php 制作一个简单的注册表单。我目前的密码字段存在问题,该字段当前将其输入显示为明文,而不是从视图中隐藏它。
?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>";
由于使用了单引号,输入类型没有注册,而不是双引号导致输入类型被逐字解释而不被用作值?
我将不胜感激对此的任何意见。谢谢!