Improvements To Member Registration Site Reg.php

Never tell user that username or password exists in this way you did die('That Username '.htmlspecialchars($_POST['member_registration_username']).' is already registered!'); its enough to tell them die('Username in use, please select another one.'); same for email.

Why using 2 query’s for check for username and email ? Its enough one to select username and email from it.

Make variables for $_POST so you don’t need to type so much, you only enters variable. Isn’t that simpler ?

Why you checking if post field is empty when you have “required” in your form, check if isset instead ?

Why you not using die(‘’); in 1 row ? I don’t see a point here to break it.

Why are you using prepared statement in if statement if ($stmt = $mysqli->prepare("INSERT INTO tbl_users (name, password) VALUES (?, ?)"))? You can easy check if data iis inserted by calling last inserted id from database connection if($mysqli->lastInsertId())

2 Likes