1) ok so you want to md5 the password before sending it... ok thats a little bit of security... but not really... what are you using to md5 it with... if your are md5ing it straight that is as good as no security... as the same md5 will be passed to your server for every password (by the same user)... were i to mimc the users login... i don't need to use the real password.. i just need to fake a post with the md5ed value i saw.. which is sent plain text across the internet
2) if you store the password plain text in your database then thats as good as no security... a hacker isn't going to screwing aroudn with your php stack to try and pull out information as its running... if they are on your computer they will just use read your databse... and all your passwords will be theirs... so either encrypt before storing or don't bother with it
md5 is pretty fast... fast enough that 4 calls won't blow your php... unless you are running apache off cygwin in windows that you installed in wine under redhat 8 that you just hacked onto your dreamcast... 🙂
you might just do think about somehting more along these lines...
1) encrypt your users password before storing in the database... md5 username and password together would work...
2) when the login form loads... start a session... store a random number there in the session and write the same id into your javascript... so now the server and the client both have the same random number that is unique to all other login pages loaded
3) before you send the password have javascript md5 the passord with the username...
4) now theoretically the password about to be sent matches the md5ed password stored in the database, so we want to do one more md5 on it. have javascript md5 it with the random number and submit the page..
5) on the server... grab the random id from the session... grab the md5ed password form the database that belongs to the user... we should be in the same boat as step 3) on the client side
6) now md5 the db password with the random id... now we should be where step 4) was on the client side
7) if it matches the one sent by the client... you win...
and this produces a unique check every login... so that a sniffer watching page requests won't see the same password being sent across to your server...
even if they see all transaction... the session_id being sent... the random number being sent... and the username and md5ed password being sent... they still won't be able to fake a login request themselves as there will be no matching session to work with...
however if they are sniffing all your traffic and have access to your server to read/write the session files so they can create a fake session file to match a fake session_id... if they have that much power already your are far beyond fucked and they are probably in a far more serious game than trying to steal your users passwords...
did i understand your script correctly... maybe i misinterpretted what you were doing and you are actually doing somehting more better like than i thought... if so please do not hesitate to defend yourself.. 🙂