可能重复:
PHP密码的安全散列和盐
我看到有人编码这样的密码哈希,
md5(uniqid(mt_rand('password', 15), true));
Run Code Online (Sandbox Code Playgroud)
这是一种安全的方式吗?甚至是成功了吗?
我找到了这个问题的答案/sf/answers/507142191/,但在我的情况下我不能放一个隐藏的字段,所以有没有办法在PHP中发布一个禁用的选择字段?
也许我错了,但对我来说它不起作用,
我正在尝试用这样的mysql_real_escape_string()功能$_POST['value'];,
mysql_real_escape_string($_POST['value']);
Run Code Online (Sandbox Code Playgroud)
但它不起作用,但如果我试试这个,
$value = $_POST['value'];
mysql_real_escape_string($value);
Run Code Online (Sandbox Code Playgroud)
它完美,任何建议为什么?
编辑:
我的代码是这样的,
$post = array('id', 'name');
$postArray = array();
foreach($post as $pa){
$postArray[$pa] = mysql_real_escape_string($_POST[$pa]);
}
Run Code Online (Sandbox Code Playgroud) 有人可以解释为什么这个简单的形式不起作用?
问题是,当我使用mysql_real_escape_string()结果什么都没有,当我删除它它完美的工作,你能看到这里有什么错吗?
这是完整的简单代码,
<?php
// Loop the post fields
$postFields = array('username', 'password', 'checkSubmission');
$postArray = array();
foreach($postFields as $postVal){
$postArray[$postVal] = mysql_real_escape_string($_POST[$postVal]);
}
print_r($postArray);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Signin</title>
<head>
</head>
<body><? echo $error;?>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post" id="signinForm">
Username: <input type="text" name="username" value="" />
Password: <input type="password" name="password" value="" />
<input type="hidden" name="checkSubmission" value="1" />
<input type="submit" name="Submit" value="Signin" />
</form>
</body> …Run Code Online (Sandbox Code Playgroud)