我们正试图完成/修复下面的代码,我们似乎无法做到以下几点。SQL/PHP如果显示其他
- 检查 'Check_Activation' 是数据库中设置为 'NULL'
- IF值为NULL直接用户的一种形式(1,2,3)
- 最后,如果' Check_Activation'已经被激活并且不是'NULL',以防止用户访问3种形式之一。
我基本知道它的存在,但我们似乎无法弄清楚最后的错误。
请快速浏览下面的代码,如果有人注意到任何不正确的东西,请通知我们。
Paste Bucket/Version
Website URL
<?php
$username = $_POST['username'];
$activation_code = $_POST['activation_code'];
$activation_codeurl = $activation_code;
$usernameurl = $username;
$db_host = "localhost";
$db_name = "aardvark";
$db_use = "aardvark";
$db_pass = "aardvark";
$con = mysql_connect("localhost", $db_use, $db_pass);
if (!$con){
die('Could not connect: ' . mysql_error());
}
mysql_select_db($db_name, $con);
$checkcustomer = mysql_query("SELECT `Check_Activation` FROM `members` WHERE `Username` = '".$username."' & `Activation` = '".$activation_code."'; ");
$array = mysql_fetch_array($checkcustomer);
if (is_null($array['Check_Activation'])) {
$username = substr($username, 0, 1);
if($username == '1') {
$redirect_url='form-one.php?membernumber='.$usernameurl.'&activation_code='.$activation_codeurl;
} elseif($username == '2') {
$redirect_url='form-two.php?membernumber='.$usernameurl.'&activation_code='.$activation_codeurl;
} elseif($username == '3') {
$redirect_url='form-three.php?membernumber='.$usernameurl.'&activation_code='.$activation_codeurl;
}
header("Location:". $redirect_url);
}
else
{
?>
您应该使用PHP的MySQLi扩展,因为MySQL扩展因安全问题已被弃用。 –