last day (15 days later) » 

11:33 PM
0
Q: Wrong login opens a session too

KathlynI have written this login php based in sqlite: <?php $db = new PDO('sqlite:data.db'); session_start(); if (isset($_SESSION['timeout'])) { if ($_SESSION['timeout'] + 4 < time()) { session_destroy(); } } else { $_SESSION['pass'] = ""; $_SESSION['timeout'] = time(); } if...

 
You are just looping through all users. You should be checking the password matches with a specific user.
 
I've been tryin to place the login code in several places in the php sheet but i dont know how to do it. Could you help me?
 
Can you format the code and provide the DB structure? Are you only storing passwords?
 
@chris85 changed the question above to show you that information
 
Okay, and you are planning to pass the user in the form?
 
11:33 PM
no, its just a trial and it just asks for password. My problem is that, when login fails (wrong password) you have to wait for the session to expire to go back to the form page.
hi chris :D
do you understand what i mean?
 
Hello, yes
so instead of the else $_SESSION['timeout'] = time()
dont set the timeout
right?
You have a bigger issue though. If 2 users have the same password you will have no way to distinguish
 
yes i bear that in mind and is not a problemm for me
the thing is
that if you introducea wrong password, which is not in the database
it doesn't redirect you directly to the form
and you have to wait for the session to expire
i'm sorry im not very good at this :(
 
Thats because the form is in an else
if (!empty($_SESSION['pass'])) {
 
how would you write it then?
 
at if (password_verify($_SESSION['pass'], $row['password'])) {
do an else and output a wrong password message and output the form again
 
11:39 PM
i dont know how to write that :((
could you answer it in the former page?
 
Sure, ill write an answer.
gimmie 5 minutes
 
thnxxxxx chris xxx
 
okay, posted.
 
it doesnt woork? sorry chirss
 
what happens?
error? no login? 500?
 
11:51 PM
there must be a syntas error as t just appears white
 
let me put it into a text editor
okay found it, too much commenting
 
i foundit myself tooo!! thankyou so so much XXX
 

last day (15 days later) »