2015-05-27 105 views
-2

我正確地做到了嗎?使用標題(「位置:....」)重定向到另一個頁面?有沒有另外一種方法來做重定向頁面?

你可以建議使用一些如MD5 encrytption的改善可能的代碼,因爲我是新來的這個東西..

<?php 
require 'db.php'; 
$msg=''; 
if(!empty($_POST['username']) && isset($_POST['username']) && !empty($_POST['password']) && isset($_POST['password'])) 
{ 
    $username = mysqli_real_escape_string($connection, $_POST['username']); 
    $password = mysqli_real_escape_string($connection, $_POST['password']); 
    $sql = mysqli_query($connection, "SELECT username FROM admin WHERE username = '".$username."' AND password ='".$password."'"); 
    $count = mysqli_num_rows($sql); 

    if($count == 1) 
    { 
     header("Location: AdminDeleteAccount.php"); 
     exit; 
    } 
    else 
    { 
     $msg='Username and Password didnt match'; 
    } 

    mysqli_close($connection); 
} 
else 
{ 
    echo 'howdie'; 
} 
?> 
+0

是的,那看起來沒問題。我建議密碼不應該以純文本格式存儲,至少它們應該被散列(用戶傾向於在多個站點上使用相同的密碼,並且如果您的數據庫被黑客入侵,那麼不僅是您的數據商店是妥協的,但所有的用戶密碼也是如此)。 –

+0

oww我真的不知道.. thnks .. – soyan

回答

0

是你正在做正確,存儲在數據庫中的密碼,SH1等還要確保在header函數之前沒有任何迴應,否則標題function將不起作用,您將看到一條錯誤消息。

相關問題