Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP true & 'true' difference
    primarykey
    data
    text
    <p>Quick question. Is there a difference between</p> <pre><code>$success = true; </code></pre> <p>and</p> <pre><code>$success = 'true'; </code></pre> <p>I know they are not '<code>==</code>' to each other, but is there a difference in using them? </p> <p>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, and stick with '=='?</p> <pre><code> $User-&gt;ProcessLogin(); $loginsuccess = $User-&gt;ProcessLogin(); if ($loginsuccess == true) { echo "&lt;big&gt;Success&lt;big&gt;&lt;br /&gt;"; echo "&lt;p&gt;We are now redirecting you to the member area.&lt;/p&gt;"; echo "&lt;meta http-equiv='refresh' content='=2;MyAccountNEW.php' /&gt;"; } elseif ($loginsuccess == false) { echo "&lt;span class='sorry'&gt;&lt;b&gt;Sorry, your account could not be found.&lt;/span&gt;&lt;/b&gt;&lt;div id='shopperlogin'&gt; &lt;img class='shopperlogintext' src='images/shopperlogin.png'&gt; &lt;br /&gt; &lt;form method='post' action='loginNEW.php' name='loginform' id='loginform'&gt; &lt;fieldset&gt; &lt;label for='username'&gt;Username:&lt;/label&gt;&lt;input type='text' name='username' id='username' /&gt;&lt;br /&gt; &lt;label for='password'&gt;Password:&lt;/label&gt;&lt;input type='password' name='password' id='password' /&gt;&lt;br /&gt; &lt;input type='submit' name='login' id='login' value='Login' /&gt; &lt;/fieldset&gt; &lt;/form&gt;&lt;/div&gt;"; } </code></pre> <p>Here's part of the class..</p> <pre><code> function ProcessLogin() { if (!empty($_POST['username']) &amp;&amp; !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-&gt;loggedin = true; $success = true; } else { $success = false; } return $success; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload