Jump to content

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.

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.