Ensuring your PHP applications are secure is crucial to protect user data and maintain trust. Learn essential security practices, including password hashing, XSS and CSRF prevention, and SQL injection protection.
htmlspecialchars() to escape user inputhtmlspecialchars() to escape special charactershtmlspecialchars()mysql_real_escape_string() for sanitizing inputhtmlspecialchars() for sanitizing user inputmysql_real_escape_string() for preventing SQL injection?
mysql_query() directly with user inputaddslashes()file_get_contents() to inspect file content| Qno | Answer (Option with the text) |
|---|---|
| 1 | C) bcrypt |
| 2 | C) To securely store passwords without reversing |
| 3 | A) password_hash() |
| 4 | B) It supports dynamic hashing and salting |
| 5 | C) bcrypt |
| 6 | A) password_verify() |
| 7 | B) To make the hash unique even for identical passwords |
| 8 | B) It uses an easy-to-reverse algorithm |
| 9 | A) A vulnerability that allows attackers to execute scripts in the user’s browser |
| 10 | A) Using htmlspecialchars() to escape user input |
| 11 | D) all of the above |
| 12 | B) Use htmlspecialchars() to escape special characters |
| 13 | B) To define which sources can execute scripts on the page |
| 14 | B) Stored XSS |
| 15 | A) A user submitting a comment that contains a script |
| 16 | A) A vulnerability that allows attackers to execute unwanted actions on behalf of authenticated users |
| 17 | C) Implementing anti-CSRF tokens in forms |
| 18 | B) It uniquely identifies legitimate requests to the server |
| 19 | C) random_bytes() |
| 20 | A) As a hidden field in the form |
| 21 | C) Reject the request and show an error |
| 22 | B) A technique to execute malicious SQL queries through user input |
| 23 | A) Using prepared statements with bound parameters |
| 24 | B) To prevent SQL injection by separating queries from user data |
| 25 | B) It may still allow some types of SQL injection attacks |
| 26 | A) Always use prepared statements and bound parameters |
| 27 | B) Fix the input validation and use prepared statements |
| 28 | B) Rename uploaded files and store them in non-public directories |
| 29 | C) finfo_file() |
| 30 | B) Validate the file extension and MIME type |