Forum Moderators: coopster

Message Too Old, No Replies

Destroying Session

via a button?

         

briesm

5:34 pm on Jun 1, 2005 (gmt 0)

10+ Year Member



Hey all, so I have a form with all sorts of data and was wondering how I could add a button, like a RESET that cleared all data but also destroyed the session.
It's easy enough to add a reset button like normal to clear fields but I want to also destroy session variables that would be passed on. An if statement that includes session_destroy seems reasonable, should I use a submit button and somehow reference whether that particular button was clicked via its name?

jatar_k

7:04 pm on Jun 1, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> should I use a submit button and somehow reference whether that particular button was clicked via its name?

exactly

briesm

8:26 pm on Jun 1, 2005 (gmt 0)

10+ Year Member



If its name was 'clear', and I wanted to end the session and clear all form variables...

I'm not sure how to make reference to it being clicked as opposed to a different submit function pointed to the same script that did something else..

if (clear) {
session_destroy();
}

?

mcibor

10:05 pm on Jun 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<input type="submit" name="clear" value="Clear the form">

<?php
if($_POST["clear"] == "Clear the form") session_destroy();?>

Hope this helps. The button is still the input. Value is passed via the post name
Best regards
Michal Cibor