Making Sticky Forms

You’ve certainly come across sticky forms, even if you didn’t know that’s what they were called. A sticky form is simply a standard HTML form that remembers how you filled it out. This is a particularly nice feature for end users, especially if you are requiring them to resubmit a form.

To preset what’s entered in a text box, use its value attribute:

<input type="text" name="name" size="20" maxlength="40" value="Brian" />

To have PHP preset that value, print the appropriate variable:

<input type="text" name="name" size="20" maxlength="40" value="<?php echo $_POST['name']; 
?>" />

With this in mind, I’ll rewrite register.php ...

Get PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.