Re: remember form input next time (cookie?)

From: Date: Wed, 04 Oct 2000 21:45:34 +0000
Subject: Re: remember form input next time (cookie?)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-18661@lists.php.net to get a copy of this message
In article <F187cy8zJByl8zD9M7T0000c2c2@hotmail.com>, ymschaap@hotmail.com ("Yvo Schaap") wrote: > Hey, I have a form that can/has to be filled in multiple times. The > information is send to a mysql with php3. I would like to browser to > remember the name and surname (cookie?!) and print it, if the form was > used > before. Or else just blank. Can you help, and write me the php code-ing? Use the same names on the succeeding forms. For example, if a form has <input type="text" name="firstname" value="<?php echo $firstname; ?>"> And no other form has been filled out, "$firstname" will be empty and so the default value will be empty. If, however, this is a form that was submitted to with firstname set, "$firstname" will have a value, and it will become the default value of that form element. What you'll probably want to do is set the form to be its own action, that is, if your form is "userinfo.php3", set the action to "userinfo.php3". If by "used before", however, you mean over long periods of time, yes, that's what cookies are for. You would probably want to store the user info in a database, and give the user a unique ID which will be a unique column in your database. Pass the unique ID as a cookie and do a lookup in the database. Start simple, however: learn to handle forms first, then learn to pass cookies, then learn to access your database, then combine everything. Jerry

« previous php.general (#18661) next »