【发布时间】:2017-04-04 22:53:03
【问题描述】:
我一直在编写一个页面,让您能够在数据库中存储密码,但我遇到了一个问题,即表格被打印了 3 次,但我不知道为什么。我希望该表位于屏幕的最右侧,并在下方列出您已输入 mysql 数据库但无法正常工作的密码
代码如下:
<?php
$tempUsername = $_SESSION['usernameBox'];
mysql_connect("localhost", "username", "password");
mysql_select_db("UserTables");
$sql = "SELECT * FROM $tempUsername";
$resultSet = mysql_query($sql);
while($info = mysql_fetch_array($resultSet)) {
$counter = count($info);
for($i = 0; $i < $counter; $i++) {
?>
<table align="right">
<th> Id </th <th> Website </th> <th> Password </th>
<tr>
<td align="center"> <?php echo $info['Id']; ?> </td>
<td align="center"> <?php echo $info['Website']; ?> </td>
<td align="center"> <?php echo $info['Password']; ?> </td>
</tr>
</table>
<?php
}
}
?>
【问题讨论】:
-
请不要以明文形式存储密码。见:crackstation.net/hashing-security.htm
-
您在迭代循环中输出一个完整的表来覆盖条目。当然,每个条目你都会得到一张完整的桌子然后......
-
在 mysql_connect 中不是我的用户名或密码,但是在表中我希望他们看到密码。
-
这仅适用于本地而非公共 :)
-
哦!!!让我看看!
标签: php mysql html-table