Php How To Not Refresh Input Values After Press Submit
I have problem, when I press submit button in my contact form all input values refreshing, it's good if all fields are filled correct, but if are some warning users must see previa
Solution 1:
a simpler way is use html5 storage . store value on onkeyup event and destroy if submit successful
for an example
<inputid="title"type="text" value="" name="article_name">
script
to check support of html5
functionsupports_html5_storage() {
try {
return'localStorage'inwindow && window['localStorage'] !== null;
} catch (e) {
returnfalse;
}
}
script to store
if(supports_html5_storage()){
$("#title").keyup(function(){
var articel_title = $("#title").val();
localStorage.setItem("articel_title",articel_title);
localStorage.getItem("articel_title");
});
to clear storage ,you can fire this if form successfully submit it will clear storage
<scripttype=text/javascript>localStorage.removeItem("articel_title");
</script>
you can also make ajax call on change or keyup event and store value to database so that if html5 is not supported by browser it will still work but it will cause more load on server
Solution 2:
return values to client:
<inputtype="text"name="val1"value="<?echo$_POST['val1']?>" />
Solution 3:
Post your values to an iframe within the page and if the entries are correct then redirect to another page.
So if the entries are wrong you would not have to do anything
Post a Comment for "Php How To Not Refresh Input Values After Press Submit"