To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
Code CritiqueHaving someone critique your code is always a great way to hone the skills. Stop in and post your code to see what your peers may have done differently.
$mysqlcon = "select * from reg_info where username = '$username' and password = '$password';";
$result = mysql_query($mysqlcon) or die("Query failed");
if (mysql_num_rows($result) == '1') {
print "<p><center><big><big>Welcome $username Please click <a href=\"isloggedin.php\">here to continue to flameline.com</big></big></center></p>";
$_SESSION["username"] = $username;
$_SESSION["password"] = $password;
$_SESSION["validuser"] = "1";
$_SESSION["loggins"] = "1";
}
else
{
$_SESSION["unvaliduser"] = "0";
print "<p><center><big><big>Sorry, incorrect Password $password. or Nickname $username.</big></big></center></p>";
print "<p><center><big>if not a member <a href=\"register.php\">click here to register</big></center></p>";
}
?>
__________________
Let the music play, it will be your getway..
$mysqlcon = "select * from reg_info where username = '$username' and password = '$password';";
$result = mysql_query($mysqlcon) or die("Query failed");
if (mysql_num_rows($result) == '1') {
print "<p><center><big><big>Welcome $username Please click <a href=\"isloggedin.php\">here to continue to flameline.com</big></big></center></p>";
$_SESSION["username"] = $username;
$_SESSION["password"] = $password;
$_SESSION["validuser"] = "1";
$_SESSION["loggins"] = "1";
} else {
$_SESSION["unvaliduser"] = "0";
print "<p><center><big><big>Sorry, incorrect Password $password. or Nickname $username.</big></big></center></p>";
print "<p><center><big>if not a member <a href=\"register.php\">click here to register</big></center></p>";
}
?>
Your code has no loops, unless they are in the include file.
HalfaBee
__________________
The lazy man always finds the best way!
Q: Who invented the auto-pilot?
A: The lazy pilot!
include_once() is marginally faster. Any reason why your selecting all instead of just the columns you need? Just a thought...
Any do you have output bufferring enabled?
__________________
Practice Sesquipedilianism (and turn Reg Globals OFF)...
IIRC, one reason is because PHP evaluates everything in double quotes (which is why you can throw variable names in there), and just treats single-quoted text as a scalar value, throwing it around as-is. Single quotes thusly provides you with a very minor performance increase.
$mysqlcon = "select * from reg_info where username = '$username' and password = '$password';";
$result = mysql_query($mysqlcon) or die("Query failed");
if (mysql_num_rows($result) == '1') {
print "<p><center><big><big>Welcome $username Please click <a href=\"isloggedin.php\">here to continue to flameline.com</big></big></center></p>";
$_SESSION["username"] = $username;
$_SESSION["password"] = $password;
$_SESSION['validuser'] = TRUE;
$_SESSION["loggins"] = "1";
} else {
$_SESSION['unvaliduser'] = FALSE;
print "<p><center><big><big>Sorry, incorrect Password $password. or Nickname $username.</big></big></center></p>";
print "<p><center><big>if not a member <a href=\"register.php\">click here to register</big></center></p>";
}
?>
BuzzLY
did you mean thate code shoulde look like this
$_SESSION['loggins'] = "1";
__________________
Let the music play, it will be your getway..
I think that the logincheck that you use is not safe. It can easily be passed using sql injection where you would just limit your answer to return one line.
You should check the password so that it actually equals the password in the database.. like this example below:
$query = "SELECT $tbl_users_uid,$tbl_users_pass,$tbl_users_isb FROM $tbl_users WHERE $tbl_users_uname='$given_user' LIMIT 1";
$result = mysql_query($query,$connection);
if(mysql_num_rows($result) != 0){
$row = mysql_fetch_assoc($result)or die(mysql_error());
/* If password is correct and user is not blocked login should be approved */
if($row["$tbl_users_pass"] == $given_pass && $row["$tbl_users_isb"]!= 1){
$_SESSION['user_name'] = $given_user;
$_SESSION['user_id'] = $row["$tbl_users_uid"];
register_login($row["$tbl_users_uid"]);
unset($_SESSION['failed_attempts']);
header('Location: index_inside.php');
}
It is taken from a login code from one of my pages and as you can see there is little hope of getting through without providing a correct password for an existing user.