EchoFool Posted March 23, 2010 Share Posted March 23, 2010 Hey, How do people make forums such as phpfreaks - where by if you press the back button your input values are not lost in the text area ? I tried with sessions, but that can be problematic in itself. Or is it some kind of HTML cache thing? Quote Link to comment Share on other sites More sharing options...
o3d Posted March 23, 2010 Share Posted March 23, 2010 If there are no javascript executed on the form when the page loaded then when you click the back button you should have the values filled in as when the form was submitted and if there were no re-directions performed. Quote Link to comment Share on other sites More sharing options...
EchoFool Posted March 23, 2010 Author Share Posted March 23, 2010 Oh so its browser cache not php ? Quote Link to comment Share on other sites More sharing options...
seaweed Posted March 23, 2010 Share Posted March 23, 2010 Why are sessions problematic? When you send the form, on the receiving page just create temp variables like this: if ($error_exists or some other condition) { $_SESSION['username'] - $_POST['username']; $_SESSION['phone'] - $_POST['phone']; header("Location: form.html"); exit; } and then on the form itself echo out the values if they are not empty like this: <form> <input type="text" name="username" value="<?php echo $_SESSION['username']; ?>" /> <input type="text" name="phone" value="<?php echo $_SESSION['phone']; ?>" /> </form> and then maybe kill the session values so they don't get re-used $_SESSION['username'] = null; $_SESSION['phone] = null; Quote Link to comment 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.