PHP Tutorials Register a New User with PHP Code This lesson is part of an ongoing User Authentication tutorial. The first part is here: User Authentication along with all the files you need. If the user is new to the site, and wants to sign up, you can add a link to a "sign up" page. Open up your signup.php page, and you'll see some code already there. We'll now walk you through what it all does. When you open up the code for the signup.php page, you'll see quite a lot of it is code that you've already met. It starts with the function that checks for dangerous SQL characters. Then we check that the form has been POSTED. The next lines are these: $uname = $_POST['username']; $pword = $_POST['password']; $uname = htmlspecialchars($uname); $pword = htmlspecialchars($pword); We're just getting the username and password from the form, like we did before, and then checking it for unwanted tags. The next thing you need to do, though, is test that the username and password are of the correct length. You don't want a malicious user trying to inject megabytes of text! What we're doing here is using the inbuilt function strlen ( ) to get the length of the string. We then use if .. else statements to check that the username and password are between certain values. If they are ok, the variable called $errorMessage is left blank. If they are not ok, we add some text for the error