【发布时间】:2013-09-26 20:14:23
【问题描述】:
<?php
include("connection2.php");
if(!empty($_POST['lrn']) && !empty($_POST['password'])){
$lrn = $_POST['lrn'];
$pass = $_POST['password'];
$check = "SELECT * from studentinf where LRN = '".$lrn."'";
$qry = mysql_query($check);
$num_rows = mysql_num_rows($qry);
$check2 = "SELECT * from studentinf where Password = '".$pass."'";
$qry2 = mysql_query($check2);
$num_rows2 = mysql_num_rows($qry2);
if($num_rows > 0){
echo "<center>LRN is valid</center> ";
}
else
echo "<font color='#FF0000'><center>Your LRN is Invalid. <br>Please Contact your Web Administrator for your LRN.</center></font>";
if($num_rows2 != "")
{
echo "account already registered";
}
else if ($num_rows2 == "")
{
echo "account not yet registered";
$query = "UPDATE studentinf SET Password = '$pass' where LRN = '$lrn'";
mysql_query($query);
echo "Thank You for Registration.";
echo '<br><a href="studentlogin.php">Click Here</a> to login your account.';
}
}
?>
【问题讨论】:
-
heremycodefixitformeplzthanks。尝试减少您的问题,并至少解释导致错误的行。
-
里面有 4 个
if语句,你遇到了哪些问题? -
嗯.. 至少它是可破解的。
-
看到你的代码我看到密码不是散列的坏主意,而且 ---------- >Please, don't use
mysql_*functions in new code。它们不再维护and are officially deprecated。看到red box?改为了解prepared statements,并使用PDO 或MySQLi - this article 将帮助您决定哪个。如果你选择 PDO,here is a good tutorial. -
^ 你们太棒了。
标签: php registration