This topic is locked
[SOLVED]

 unset $_SESSION variables

10/9/2009 12:17:04 AM
PHPRunner General questions
M
meirco author

I used session variable to store values from previous entries as per manual . works good.

now if i want to have a button to clear the session.
function clearit()

{

unset($_SESSION['mattkey']);

unset($_SESSION['bmbmno']);

unset($_SESSION['code2']);

}
//** Display a message on the Web page ****

echo "To Clear Fields Click the button";
<FORM>

<INPUT TYPE="button" VALUE="CLEAR" onClick="clearit();">

</FORM>
where do you put the code and of course it is BUGGY.
Thaks

J
Jane 10/9/2009

Hi,
you've mixed PHP, JavaScript and HTML code.

Here are some changes:

echo "To Clear Fields Click the button";
$str = "<FORM>

<INPUT TYPE=\"button\" VALUE=\"CLEAR\" onclick=\"window.location.href='tablename_list.php?clear=yes\">

</FORM>";

echo $str;


Then check passed parameter in the Before process event and use your code:

if (@$_REQUEST["clear"]=="yes")

{

...

}
M
meirco author 10/11/2009



Hi,
you've mixed PHP, JavaScript and HTML code.

Here are some changes:

echo "To Clear Fields Click the button";
$str = "<FORM>

<INPUT TYPE=\"button\" VALUE=\"CLEAR\" onclick=\"window.location.href='tablename_list.php?clear=yes\">

</FORM>";

echo $str;


Then check passed parameter in the Before process event and use your code:

if (@$_REQUEST["clear"]=="yes")

{

...

}




Jane Thank you again for all your help.

as a newbee I try to grasp the entire aspect of it all. determined I set out on this project and I will learn it all

in the shortest time possible.

having said that .

i took what you suggested



$str = "<FORM>

<INPUT TYPE=\"button\" VALUE=\"CLEAR\" onclick=\"window.location.href='tablename_list.php?clear=yes\">

</FORM>";

echo $str;



and entered it as code snippet in my VE addpage replaced tablename_list.php with time_add.php

I put this in Before process event in addpage



if (@$_REQUEST["clear"]=="yes")

{

unset($_SESSION['mattkey']);

unset($_SESSION['bmbmno']);

unset($_SESSION['code2']);

}


so having done all that I got the button and when I click and click and click NADA nothing happens.

well I looked and looked and then I decided to roll my sleeves up and understand what is exactly your code is doing

and then I found it . 'tablename_list.php?clear=yes is missing the closing '

voila it works. I'm learning.

Thanks again.

Meir

M
meirco author 10/14/2009



Jane Thank you again for all your help.

as a newbee I try to grasp the entire aspect of it all. determined I set out on this project and I will learn it all

in the shortest time possible.

having said that .

i took what you suggested



$str = "<FORM>

<INPUT TYPE=\"button\" VALUE=\"CLEAR\" onclick=\"window.location.href='tablename_list.php?clear=yes\">

</FORM>";

echo $str;



and entered it as code snippet in my VE addpage replaced tablename_list.php with time_add.php

I put this in Before process event in addpage



if (@$_REQUEST["clear"]=="yes")

{

unset($_SESSION['mattkey']);

unset($_SESSION['bmbmno']);

unset($_SESSION['code2']);

}


so having done all that I got the button and when I click and click and click NADA nothing happens.

well I looked and looked and then I decided to roll my sleeves up and understand what is exactly your code is doing

and then I found it . 'tablename_list.php?clear=yes is missing the closing '

voila it works. I'm learning.

Thanks again.

Meir


Hi Jane

How do we fix this code so it doesn't break Internt Explorer (MSIE)



$str = "<FORM>

<INPUT TYPE=\"button\" VALUE=\"CLEAR\" onclick=\"window.location.href='tablename_list.php?clear=yes'\">

</FORM>";

echo $str;
J
Jane 10/15/2009

Hi,
here is just a sample:

$str = "<INPUT TYPE=\"button\" VALUE=\"CLEAR\" onclick=\"window.location.href='tablename_list.php?clear=yes\">";

echo $str;