login with username or email address in php

前端 未结 8 2283
面向向阳花
面向向阳花 2021-02-01 10:56

I am trying to create a login with username or email

My code is:

$username=$_REQUEST[\'login\'];
$email=$_REQUEST[\'login\'];
$password=$_REQUEST[\'passw         


        
8条回答
  •  無奈伤痛
    2021-02-01 11:42

    You are setting the same value to two variables, and then using an if/else. Both if statements are equivalent.

    You need to figure out if $_REQUEST[login] contains a valid email address, and if so use the email field of the database. Otherwise, use the username field.

    Also, you should not be putting variables directly into the query. Use prepared statements.

提交回复
热议问题