更新的代碼仍然不起作用?登錄加密密碼進行比較
<?php
$host="localhost";
$username="root";
$password="power1";
$db_name="members";
$tbl_name="users";
string sha1 (string $Password [, bool $raw_output = false ])
$link = mysql_connect("$host", "$username", "$password")or die("cannot connect. Please contact us");
mysql_select_db("$db_name")or die("cannot select DB. Please contact us");
$Email=$_POST['Email'];
$Password=$_POST['Password'];
$Email = stripslashes($Email);
$Password = stripslashes($Password);
$Email = mysql_real_escape_string($Email);
$Password = mysql_real_escape_string($Password);
$sql="SELECT * FROM $tbl_name WHERE Email='$Email' AND password ='$Password'";
$result=mysql_query($sql, $link) or die ('Unable to run query:'.mysql_error());
$count=mysql_num_rows($result);
if($count==1){
session_register("Email");
session_register("Password");
header("location:login_success.php");
}
else {
echo "Wrong Email or Password. Please Wait.<meta http-equiv='REFRESH' content='1;url=login.php'>";
}
?>
我很抱歉,但我很初學者,我會如何去做這件事?對不起 – spencer
查看最新的答案。 – cweiske
謝謝你,所以我會把這個,而不是: 函數加密($密碼,$密鑰){ $結果='';對於($ i = 1; $ i <= strlen($ Password); $ i ++)$ $ char = substr($ Password,$ i-1,1); $ keychar = substr($ key,($ i%strlen($ key)) - 1,1); $ char = chr(ord($ char)+ ord($ keychar)); $ result。= $ char; } return asc2hex($ result); } $ sql =「SELECT * FROM $ tbl_name WHERE Email ='$ Email'AND password ='$ Password'」; ($ sql = $ link)或死('無法運行查詢:'。mysql_error()); – spencer