jriggs Posted September 11, 2008 Share Posted September 11, 2008 php beginner here. I'm working on a registration form that will post some values to a php page, which in turn redirects to a thank you page. I plan on using javascript to do some basic data validation, but I also will need to connect to a database to re-validate the data. Suppose the form passes the javascript validation, but fails the db stuff on the php page: - How would I redirect back to the html page, but automatically populate whatever fields the user has already filled in? Is there a preferred method to accomplish this? Thanks for any suggestions- Link to comment https://forums.phpfreaks.com/topic/123781-set-values-on-html-page-with-php/ Share on other sites More sharing options...
DeanWhitehouse Posted September 11, 2008 Share Posted September 11, 2008 To repopulate the fields do (if you are using post) <input type="text" value="<?php if(isset($_POST['field1'])) {echo $_POST['field1'];} ?>" name="field1"> Link to comment https://forums.phpfreaks.com/topic/123781-set-values-on-html-page-with-php/#findComment-639123 Share on other sites More sharing options...
seangamer Posted September 12, 2008 Share Posted September 12, 2008 Could you not just have php write a quick js script instead of new page if error? i.e: if(PASSED) { ... } else { echo('<script type="text/javascript">window.location.history.back();</script>'); } Oor something to that effect. I'm not sure about IE but with FF the browser automatically remembers the form information filled. Hope this helps! Link to comment https://forums.phpfreaks.com/topic/123781-set-values-on-html-page-with-php/#findComment-639481 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.