Learn how to insert new data into the database
CREATE (INSERT) is the operation used to add new data to the database. It takes data from a form, validates it, and stores it permanently in the database.
CREATE operations are used whenever you sign up for a service, create a new account, add a new product to an e-commerce store, or post on social media.
User fills out a form with student information (name, email, class, status)
PHP checks: Are all fields filled? Is the email valid? Is there a valid status?
Create a prepared statement to prevent SQL injection attacks
Run the SQL INSERT command to add the new record to the database
Show success message and clear the form or redirect to list of students
The form below shows how a CREATE operation looks and feels. To actually create students in the database, you need to login to the admin panel. This keeps your data safe by requiring authentication.
Required, non-empty, max 100 characters
Required, must be valid email format (contains @)
Required, non-empty, max 50 characters
Required, must be 'active' or 'inactive'
We use prepared statements to prevent SQL injection attacks. This separates the SQL query from the data.
All inputs are validated before being stored in the database to ensure data quality.
Now that you understand the CREATE operation, explore the other operations: