md5加密问题
<?php
include("config.php");
include("conn.php");
if($_POST['submit']){
$sql="insert into user (uid,m_id,username,password) " .
"values ('','','$_POST[username]','md5($_POST[password].all_ps)')";
mysql_query($sql);
echo "<script language=\"javascript\">alert('注册成功');history.go(-1)</script>";
}
?>
<link href="images/css.css" rel="stylesheet" type="text/css">
<form action="" method="post" >
用户名:<input type="text" name="username" size="40" maxlength="40"/><br/>
密码:<input type="password" name="password" size="40" maxlength="40"/>
<br/>
<input type="submit" name="submit" value="注册"/>
</form>
点击“注册”按钮后数据库中password字段的内容并没有被MD5加密,例如我密码输入“123",数据库里的内容就是
md5(123.all_ps),求教怎么回事啊。(all_ps是个常量)
[解决办法]
'md5($_POST[password].all_ps)'
PHP只会处理字符串中的变量,也就是$_POST['password']. 你最好先把结果写入一个变量
[解决办法]
修改你的SQL
$sql = "insert into user (uid,m_id,username,password) " . "values ('','','{$_POST['username']}','" . md5 ( $_POST ['password'] ) . all_ps . "')";