我想清理我的登录脚本并帮助我的数据库安全。我是一个基本的编码员,从教程中学到了我所拥有的东西,所以我想我的脚本需要一些保护,有什么建议吗?
<?php
session_start();
$email = strtolower( trim($_POST['email']));
$pass = $_POST['password'];
if ($email&&$pass){
require_once("dbconnect.php");
$query = mysql_query("SELECT * FROM users WHERE username='$email'");
$numrows = mysql_num_rows($query);
if ($numrows!=0){
//code to login
while ($row = mysql_fetch_assoc($query)){
$dbusername = $row['username']; //USERNAME IS NAME OF COLUMN IN DB
$dbpassword = $row['password'];
$activated = $row['activated'];
if ($activated=='0')
die("Your account has not been activated.(Remember to check in your email spam folder)");
}
//check to see if they match
if ($email==$dbusername&&md5($pass)==$dbpassword){
//echo "You have succesfully logged-in! <a href='start.php'>Click</a> here to enter." ;
$_SESSION['username']=$email;
header( 'Location: http://website' ) ;
}
else{
echo "The password you entered is incorrect";
}
}
else
die("Sorry, the email you have entered is incorrect");
}
else
die("Please enter your email and password");
?>