Jump to content

Recommended Posts

<?php include 'data.php'; 
ob_start();
session_start();
if(isset($_POST['submit'])) { 

// username and password sent from form 
$username=$_POST['username']; 
$password=$_POST['password']; 
$enc=md5($_POST['password']);

$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);


$sql=mysql_query("SELECT * FROM pilots WHERE username='$username' AND password='$enc' AND admin='yes' || admin='hub'");
$omg = mysql_num_rows($sql);

if($omg > 0){
while($row = mysql_fetch_array($sql)){

$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
$_SESSION['admin'] = $row['admin'];
$_SESSION['hub'] = $row['hub'];

header ('Location: successadm.php');	
mysql_close($connection);
}
} 
else {
echo "Wrong Username/Password";
}}
?>         
<center>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
            <fieldset>
            <div> <br />
              <label for="txtusername">Username:</label>
              <input type="text" name="username" value="" title="Text input: Username" id="txtusername" maxlength="20" />
            </div>
            <div>
              <label for="txtpassword"> Password:</label>
              <input type="password" name="password" title="Text input: Password" id="txtpassword" maxlength="20" />
            </div>
            <br />
            <div>                
              <input type="submit" name="submit" value="Login" />
              <input type="submit" name="ResetButton" title="Reset button: Login" id="btnReset" value="Clear" class="button" />
              <br />
              </div>
            </fieldset>
          </form> 
<font color="red">
</font>
</center>

If I press login in it will automatily bring me to admin area why is that?

 

Thank You

Link to comment
https://forums.phpfreaks.com/topic/147616-login/
Share on other sites

Try changing this:

 

$sql=mysql_query("SELECT * FROM pilots WHERE username='$username' AND password='$enc' AND admin='yes' || admin='hub'");

 

to this:

 

$sql=mysql_query("SELECT * FROM pilots WHERE username='$username' AND password='$enc' AND (admin='yes' OR admin='hub')");

Link to comment
https://forums.phpfreaks.com/topic/147616-login/#findComment-774921
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.