dames dames - 11 months ago 75
HTML Question

Refresh page without losing the Post value

How do I maintain the $post value when a page is refreshed; In other words how do I refresh the page without losing the Post value


This in not possible without a page submit in the first place! Unless you somehow submitted the form fields back to the server i.e. Without Page Refresh using jQuery etc. Somesort of Auto Save Form script.

If this is for validation checks no need for sessions as suggested.

User fills in the form and submits back to self Sever side validation fails


    <input type="hidden" name="first" 
   value="<?php echo htmlspecialchars($first, ENT_QUOTES); ?>" />

validation message, end.

alternatively as suggested save the whole post in a session, something like this, but again has to be first submitted to work....


if(isset($_POST) & count($_POST)) { $_SESSION['post'] = $_POST; }
if(isset($_SESSION['post']) && count($_SESSION['post'])) { $_POST = $_SESSION['post']; }