Jump to content


Photo

Requesting Info...Help!


  • Please log in to reply
2 replies to this topic

#1 melvnatic

melvnatic
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 24 April 2006 - 02:30 AM

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!

#2 melvnatic

melvnatic
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 24 April 2006 - 08:00 PM

actually, i meant form fields...how do you create a box where, when the user presses submit, it saves the info to a variable?

#3 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 24 April 2006 - 08:06 PM

Generally, the page has to be reloaded in order to take input from a field and put it into a variable:
<?php
if(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>
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();




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users