Jump to content

[SOLVED] Login doesn't work


Nordskjold

Recommended Posts

Hi everybody, I'm atm testing my login php script but the weird about it is that when i tell it to get all users in the DB and put them in an array, it only takes and logs in the first in line (in the DB) the rest of the users in the DB kinda don't exist :s

Have a look:

 

<?php

session_start();

 

$sess = FALSE;

 

if (isset($_SESSION['bruger']) && isset($_SESSION['password']))

{

$sess = TRUE;

}

 

if ($sess == FALSE)

{

$output = '

<form action="" id="login_form" name="login_form" method="post">

<table>

<tr>

<td width="145px"></td>

<td><a name="registrering">Log ind  </a></td>

<td><input type="text" id="login_brugernavn" name="login_brugernavn" tabindex="1" /></td>

<td><input type="password" id="login_password" name="login_password" tabindex="2" /></td>

</tr>

<tr>

<td></td>

<td><a name="registrering" href="../registrering/index.php" class="linkz">Registrer</a></td>

<td></td>

<td align="right"><input type="submit" id="submit" name="submit" value="Login" tabindex="3" /></td>

</tr>

</table>

</form>';

 

require("connect_my_db.php");

 

$resultat = mysql_query("SELECT * FROM brugere");

 

if (isset($_POST['submit']))

{

if (!$_POST['login_brugernavn'] || !$_POST['login_password'])

{

echo "<span class='fejl_message'>*Du mangler at udfylde nogle felter*</span>";

}

while ($bruger = mysql_fetch_assoc($resultat))

{

if (($bruger['Brugernavn'] <> $_POST['login_brugernavn']) || ($bruger['Kodeord'] <> $_POST['login_password']))

{

echo "<span class='fejl_message'>*Brugeren eksistere ikke*</span>";

break;

}

else if (($bruger['Brugernavn'] == $_POST['login_brugernavn']) && ($bruger['Kodeord'] == $_POST['login_password']))

{

if (($bruger['Value'] == 3))

{

echo "<span class='fejl_message'>*Din bruger er blevet bannet i 2 uger*</span>";

break;

}

else if (($bruger['Value'] == 0))

{

echo "<span class='fejl_message'>*Du er blevet slettet*</span>";

break;

}

else

{

$_SESSION['bruger'] = $bruger['Brugernavn'];

$_SESSION['password'] = $bruger['Kodeord'];

header('Location: ../');

}

}

}

}

}

 

if ($sess == TRUE)

{

$output = '<form action="" id="logout_form" name="logout_form" method="post">

  <div style="float:right; padding:15px 35px 0px 0px;"><input type="submit" id="logout" name="logout" value="Logout" /></div>

  </form>';

 

if (isset($_POST['logout']))

{

session_destroy();

header('Location: ../');

}

}

?>

 

I really need help on this one, been driving me mad for days now..

Link to comment
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.