An Option for Repeat Attempts PHP Help

At this point. your sign-in page is functionally complete. However, there’s one more option that you can provide to your users: reloading their user name on login failure. Some sites do this, and some don’t. It’s a matter of opinion, but even if you choose not to implement this feature, you should know hew to implement it.

If you need to display a user name, this means that the user has already submitted the form at least once before. That places you squarely in this portion of sigin.php.

if (isset($_POST[‘username’]» {
// Try and log the user in
$username ; mysql_real_escape_string(trim($_REOUEST[‘username’]»;
$password ; mysql_real_escqpe_string(trim($_REOUEST[‘password’]»;
// and so on …
The user name has been sent, but the login failed. However, you still have the $username variable ready to display.

Now, move-Into the HTML. You can set the value of a form field with the value attribute, and you’ve got the attribute value in $username. Put that together, and you’ll end up with something like this:

<label for;”username”>Username:</label>
<input type;”text” name;”username” id;”username” size;”20″
value=”<?php if (isset($username» echo $username; ?>” I>

That’s all there is to it. Enter a user name, submit the sign-in page, and you should see an error, but now you’ll also see the previously entered user name. Take a look at Figure 13-9 for the details.



Posted on January 14, 2016 in Cookies, Sign- Ins, and Ditching Crummy Pop-Ups

Share the Story

Back to Top
Share This