Jump to content

[SOLVED] Combining two conditions?


merylvingien

Recommended Posts

Hi fellas, a bit stuck with this simple check.

I have a page where users can log in, but i want to be sure that it is properly protected, so i think i am overdosing on security, anyway i am trying two checks for proper email and password, first against the database and second in the page coding.

Why you might ask, i dont know LOL

Anyway i am stuck here.

I havent tried to combine two conditions together before, so i am not sure if this is correct also i am pulling a hashed password from the database, so i am not sure if i am coding that part correctly in this situation:

if ($email = "$row[email]") && ($password = "$row[md5'password']")
{ continue as normal

How should this statment be coded, i have tried it this way, that way and upside down.

Link to comment
https://forums.phpfreaks.com/topic/181300-solved-combining-two-conditions/
Share on other sites

if you want to check equality use the comparison operator (==) or identical operator (===) not the assignment operator(=) what that is doing is setting $email to $row['email']

 

if ($email == $row['email']) && ($password == $row['md5password'])
{ continue as normal

 

also surround associative array keys with single quotes

You think my parenthesis is bad, you should have seen my school reports LOL

 

 

FaT3oYCG i was just about to mention the fact that i cannot log in anymore LOL

 

if ($email == $row['email'] && $password == $row[md5('password']))

  is that correct?

I will try it, but as i am here writing and may benifit other readers at some point  :shrug:

 

Edit: nope LOL

oh, well you are doing that completely wrong.

 

assuming that the password is already md5'ed in the database

if ($email == $row['email'] && md5($password) == $row['password'])

 

what you did there didn't really even make any sense. you were trying to md5 the string 'password' followed by a square bracket, and use that md5'ed string as the key in the $row array.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.