0% found this document useful (0 votes)
10 views1 page

User Authentication System in PHP

The document outlines an exercise to develop a user authentication system in PHP and MySQL, including both vulnerable and secure implementations. It details the steps for creating a database schema, user registration, and login functionality while emphasizing the risks of SQL injection. The exercise aims to demonstrate the effectiveness of prepared statements and input validation in preventing SQL injection attacks.

Uploaded by

ragz autentic
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

User Authentication System in PHP

The document outlines an exercise to develop a user authentication system in PHP and MySQL, including both vulnerable and secure implementations. It details the steps for creating a database schema, user registration, and login functionality while emphasizing the risks of SQL injection. The exercise aims to demonstrate the effectiveness of prepared statements and input validation in preventing SQL injection attacks.

Uploaded by

ragz autentic
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Source code activity

Exercise: Implement User Authentication System

Description: Develop a user authentication system for a web application using PHP and
MySQL. Implement both vulnerable and secure versions to demonstrate the risks of
SQL injection and how to prevent them using prepared statements and proper input
validation.

Instructions:

1. Design a database schema to store user credentials. Create a table named


"users" with columns for "id" (INT), "username" (VARCHAR), and "password"
(VARCHAR).
2. Implement user registration functionality in PHP. Create forms to allow users to
register by providing a username and password. Store the user credentials
securely in the "users" table.
3. Develop login functionality with two versions: a. Vulnerable version: Concatenate
user input directly into the SQL query to check for user credentials. b. Secure
version: Use prepared statements and parameterized queries to validate user
credentials securely.
4. Test both versions of the login functionality by attempting to log in with valid and
invalid credentials. Additionally, try injecting SQL commands into the vulnerable
version to demonstrate the risk of SQL injection.
5. Compare the behaviors of the vulnerable and secure versions. Show how the
secure version prevents SQL injection attacks while the vulnerable version is
susceptible.
6. Provide explanations and comments in your code to clarify the differences and
highlight the importance of using prepared statements and proper input validation
for SQL injection prevention.

You might also like