PDA

View Full Version : Best way of temp storing infomation?



Moh
23-08-2008, 07:58 PM
Well say on a register page, if you get a field wrong, normaly you would have to enter them all again. So what would be the best way so that if you get a field wrong, the information is saved.

Moved by Invent (Forum Moderator) from Designing & Development: Please post in the correct forum next time, thanks :).

MrCraig
23-08-2008, 08:03 PM
Cookies :D

Moh
23-08-2008, 08:10 PM
Cookies :D
Thought so :P

Hypertext
23-08-2008, 08:18 PM
Or you could make it really clever and have a MySQL memory table. Although cookies would suffice.

Delatory
23-08-2008, 08:43 PM
If you was processing the data on the same page you could just put a value on the field and put <? echo $_POST[FIELD NAME]; ?> or w.e it is in the language your using and do it that way

Moh
23-08-2008, 08:51 PM
Or you could make it really clever and have a MySQL memory table. Although cookies would suffice.
Cookies would be easier, then i dont have to do much.

Humm, I having a problem though. When I submit the form and its wrong, it displays the old cookies the time before.
I have made it update the cookies before returning them also.

Edit: *slaps self*
I just remembered, when im posting to the same page, I dont have to xD

Decode
23-08-2008, 09:10 PM
I just do



if ($_GET['action'] === send) {
//validatecode
if ($validate === done) {
//add to db or flatfile code
header ( location: done.php );
}
}
$age = addslashes( $_POST['age'] );
echo ('<form action="?action=send" method="post">');
echo ('<input type="text" name="age" value="$age">');
echo ('<input type="submit">
echo ('</form>');

Dentafrice
23-08-2008, 09:13 PM
Or you could make it really clever and have a MySQL memory table. Although cookies would suffice.

There's no point in that, that's wasting database space, if a user doesn't finish the registration (and sufficing you have specified for it to be removed), it's not going to be removed.

Of course there are other ways to remove it, but that's just more work for such a simple task.


Cookies would be easier, then i dont have to do much.

Humm, I having a problem though. When I submit the form and its wrong, it displays the old cookies the time before.
I have made it update the cookies before returning them also.

Edit: *slaps self*
I just remembered, when im posting to the same page, I dont have to xD

I wouldn't recommend cookies.

Just use sessions, easy enough, and they only last for that browser session, so there's no worrying about wasted data.

MrCraig
23-08-2008, 09:18 PM
yeah but at least with cookies, if the browser freakishly closes then theres no need to re-input the data.

All depends whether you want that to happen or not.

Dentafrice
23-08-2008, 09:21 PM
Yeah, but if cookies are turned off? ;) Then it isn't going to work, at least with sessions it's going to work without relying exclusively on browser settings.

Moh
23-08-2008, 10:29 PM
I don't need this anyone, I just simply used $_POST["username"] as the value :P

Want to hide these adverts? Register an account for free!