Jump to content

Archived

This topic is now archived and is closed to further replies.

melvnatic

Requesting Info...Help!

Recommended Posts

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!

Share this post


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

Share this post


Link to post
Share on other sites
Generally, the page has to be reloaded in order to take input from a field and put it into a variable:
[code]<?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>[/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();

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.