Trying to check if username already exists in MySQL database using PHP

后端 未结 8 1892
无人共我
无人共我 2020-12-28 10:12

I\'ve looked at the many other posts that were similar to my issue and implemented their solutions (as far as I can tell) as exactly as I could. However, every time I execut

8条回答
  •  萌比男神i
    2020-12-28 10:47

    Try this:

    $query = mysql_query("SELECT username FROM Users WHERE username='$username' ")
    

    Don't add $con to mysql_query() function.

    Disclaimer: using the username variable in the string passed to mysql_query, as shown above, is a trivial SQL injection attack vector in so far the username depends on parameters of the Web request (query string, headers, request body, etc), or otherwise parameters a malicious entity may control.

提交回复
热议问题