melvnatic Posted April 24, 2006 Share Posted April 24, 2006 How do you ask a visitor something and store his/her reply to a variable? And also, is it possible to delete a session variable when the visitor closes the browser or exits the page? Thank you! Quote Link to comment Share on other sites More sharing options...
melvnatic Posted April 24, 2006 Author Share Posted April 24, 2006 actually, i meant form fields...how do you create a box where, when the user presses submit, it saves the info to a variable? Quote Link to comment Share on other sites More sharing options...
zq29 Posted April 24, 2006 Share Posted April 24, 2006 Generally, the page has to be reloaded in order to take input from a field and put it into a variable:[code]<?phpif(isset($_POST['name'])) { $name = $_POST['name']; echo "Your name is $name!";}?><form name="name" action="" method="post"> <input type="text" name="name"/> <input type="submit" name="submit" value="GO!"/></form>[/code]With regards to session variables, I think they are destroyed when the browser is closed, although you could clear the session data with something like $_SESSION = array(); 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.