Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Student Registration Form

A complete HTML + CSS + JavaScript + PHP/MySQL student registration form: client-side validation, an AJAX submit (no page reload), server-side validation, hashed passwords, and an optional profile-photo upload.

Files

File Purpose
index.html The form markup
style.css Styling
script.js Client-side validation + fetch() submit
register.php Server-side validation, hashing, and DB insert
db_connect.php PDO/MySQL connection (edit your credentials here)
database.sql Creates the database and students table
uploads/ Where uploaded profile photos are stored

Setup

  1. Requirements: PHP 7.4+ with PDO MySQL, and MySQL or MariaDB.
  2. Import the schema:
    mysql -u root -p < database.sql
  3. Edit db_connect.php and set DB_HOST, DB_NAME, DB_USER, DB_PASS to match your setup.
  4. Keep all files in one folder (e.g. your project root or htdocs/student-registration/) — the HTML references style.css, script.js, and register.php as relative paths.
  5. Run it through a PHP server (opening index.html directly as a file:// URL won't work, since the form's fetch() call needs an HTTP origin):
    php -S localhost:8000
    Then visit http://localhost:8000. This also works unchanged under XAMPP, WAMP, MAMP, or a shared PHP host.
  6. Make sure the uploads/ folder is writable by PHP (chmod 755 uploads, or 775 if your web server user needs group write access). register.php will also try to create it automatically if it's missing.

How it works

  • script.js validates every field on blur/change and again on submit, then sends the data as FormData to register.php via fetch(). It reads back a JSON response and shows a success banner or highlights the specific fields the server rejected.
  • register.php re-validates everything server-side (client-side checks can always be bypassed), checks the email isn't already registered, hashes the password with password_hash(), stores the optional photo under uploads/ with a randomized filename, and inserts the record using a prepared PDO statement.

Before using this in production

This covers the core registration flow, but a production deployment should add:

  • HTTPS everywhere (passwords and personal data are sent in the request body).
  • CSRF protection on the form submission.
  • Rate limiting / a CAPTCHA on register.php to deter automated sign-ups.
  • A proper session/login system to go along with this registration step.
  • Server-level file-size limits (upload_max_filesize, post_max_size in php.ini) that match the 2MB check in the code.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages