EchoFool Posted January 30, 2008 Share Posted January 30, 2008 Is there a way with forms that if a user registers and it doesn't work and the user has to go back, the data will still remain so they don't have to re-fill the whole form again.. what do they use to do this ? Is it standard HTML stuff or php? Quote Link to comment https://forums.phpfreaks.com/topic/88616-lost-data-on-page-refresh/ Share on other sites More sharing options...
themistral Posted January 30, 2008 Share Posted January 30, 2008 This is php - do a web search for something like 'php sticky forms' and you should be able to find a tutorial! Quote Link to comment https://forums.phpfreaks.com/topic/88616-lost-data-on-page-refresh/#findComment-453722 Share on other sites More sharing options...
pocobueno1388 Posted January 30, 2008 Share Posted January 30, 2008 You could store the information into sessions. So lets say they submit the form and one of the fields was their first name. $_SESSION['first_name'] = $_POST['first_name']; Now when they have to go back to the form, your form code should look like this. <input type="text" name="first_name" value="<?php if(isset($_SESSION['first_name'])) echo $_SESSION['first_name']; ?>"> Quote Link to comment https://forums.phpfreaks.com/topic/88616-lost-data-on-page-refresh/#findComment-453727 Share on other sites More sharing options...
EchoFool Posted January 31, 2008 Author Share Posted January 31, 2008 You could store the information into sessions. So lets say they submit the form and one of the fields was their first name. $_SESSION['first_name'] = $_POST['first_name']; Now when they have to go back to the form, your form code should look like this. <input type="text" name="first_name" value="<?php if(isset($_SESSION['first_name'])) echo $_SESSION['first_name']; ?>"> I tried this.. works kinda... works when the session exists.. how ever if the session was not created, I get an error saying undefined variable... would it still work with a if isset check prior to echo'in the values? Quote Link to comment https://forums.phpfreaks.com/topic/88616-lost-data-on-page-refresh/#findComment-454333 Share on other sites More sharing options...
pocobueno1388 Posted January 31, 2008 Share Posted January 31, 2008 would it still work with a if isset check prior to echo'in the values? Thats exactly what it does...did you change the code I gave you? Quote Link to comment https://forums.phpfreaks.com/topic/88616-lost-data-on-page-refresh/#findComment-454376 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.