Hızlı bir soru. Arasında bir fark var mı
$success = true;
ve
$success = 'true';
Ben onlar '==
' birbirine değil biliyorum, ama bunları kullanarak bir fark var?
EDIT: I found that using '===' instead of '==' when seeing if $success is false solved my problem. My question now is that, should I just use strings in a case like below, ve stick with '=='?
$User->ProcessLogin();
$loginsuccess = $User->ProcessLogin();
if ($loginsuccess == true) {
echo "<big>Success<big><br />";
echo "<p>We are now redirecting you to the member area.</p>";
echo "<meta http-equiv='refresh' content='=2;MyAccountNEW.php' />";
}
elseif ($loginsuccess == false) {
echo "<span class='sorry'><b>Sorry, your account could not be found.</span></b><div id='shopperlogin'> <img class='shopperlogintext' src='images/shopperlogin.png'>
<br />
<form method='post' action='loginNEW.php' name='loginform' id='loginform'>
<fieldset>
<label for='username'>Username:</label><input type='text' name='username' id='username' /><br />
<label for='password'>Password:</label><input type='password' name='password' id='password' /><br />
<input type='submit' name='login' id='login' value='Login' />
</fieldset>
</form></div>";
}
İşte sınıfın parçası ..
function ProcessLogin() {
if (!empty($_POST['username']) && !empty($_POST['password'])) {
$username = mysql_real_escape_string($_POST['username']);
$password = md5(mysql_real_escape_string($_POST['password']));
$checklogin = mysql_query("SELECT * FROM users WHERE Username = '".$username."' AND Password = '".$password."'");
if(mysql_num_rows($checklogin) == 1)
{
$row = mysql_fetch_array($checklogin);
$email = $row['EmailAddress'];
$_SESSION['Username'] = $username;
$_SESSION['EmailAddress'] = $email;
$_SESSION['LoggedIn'] = 1;
$this->loggedin = true;
$success = true;
}
else {
$success = false;
}
return $success;
}
}