|
Posted by Ian Davies on 06/23/06 21:49
Thank you for your response
Your suggestion was what I was looking for
Although I couldnt get it to work properly with the javascript I did manage
to get it to work using
<?php
session_start();
header("Cache-control: private, no-store, no-cache, must-revalidate"); // IE
6 Fix.
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$_SESSION['savedcomm']='';
$_SESSION['pupilfield']='';
$_SESSION['gender']='';
header("Location: http://www.mysite.co.uk/folder/file.php");
?>
instead of your page three
thanks
ian
"Mtregael" <gael.r0001@numericable.fr> wrote in message
news:4499cc7a$0$166$a3f2974a@nnrp1.numericable.fr...
Ian Davies a ιcrit :
> Hello
> I am struggling for a solution to clear some fields on my webpage that
takes
> their values from some sessions
> My solution below works when the button is clicked twice. I sort of know
why
> I have to click it twice to do the job (the first submit resets the
sessions
> but this it too late to change the field values, which requires another
> submit to pick up the new session values). Problem is I cant think how to
> accomplish the resetting of the fields to nothing with one click
>
> Code so far(below)
> **********************************
> <form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF'];
> ?>">
> <input name="Submit" type="submit" value=" Clear ">
>
> <?php
> if(isset($_POST['Submit'])){
> $_SESSION['savedcomm']='';
> $_SESSION['pupilfield']='';
> $_SESSION['gender']='';
> }
> ?>
>
> </form>
> ****************************
>
> Help greatly appreciated
> Ian
>
>
Hi,
Here is ONE example (i think there are many others...) that work to
'clear' some session variables:
1st page:
test1.php:
<?php
session_start();
$_SESSION['param1']="Param1";
$_SESSION['param2']="Param2";
$_SESSION['param3']="Param3";
?>
<html>
<head>
<title>Test 1</title>
</head>
<body>
<a href=test2.php>Next...</a>
</body>
2nd page:
test2.php:
<?php
session_start();
?>
<html>
<head>
<title>Test 2</title>
</head>
<body>
<?php
$param1=$_SESSION['param1'];
$param2=$_SESSION['param2'];
$param3=$_SESSION['param3'];
echo "Param1: ".$param1."<br>";
echo "Param2: ".$param2."<br>";
echo "Param3: ".$param3."<br>";
?>
<form>
<input type=button name=reset value=reset
onclick="javascript:window.open('popup.php');">
</form>
</body>
3st page:
popup.php:
<?php
session_start();
$_SESSION['param2']='';
?>
<html>
<head>
<title>Test fenetre popup</title>
</head>
<body onload="javascript:opener.location.reload();self.close();">
</body>
I explain:
test1.php: set some sessions variables 'param1' to 'param3'
The "Next..." link to test2.php
test2.php: show the session variables. One button "Reset" that call
popup.php page
popup.php: Clear the value of session variable 'param2', reload parent
and close itself.
When test2.php reload, you can see that 'param2' value is empty (but is
set !)
This need to have javascript enabled. Popup blockers don't block this
'popup' because it is called directly from a button.
You should not have actions on test2.php becaus it is reloaded after
clicking 'reset' button.
I hope this can help you...
Regards,
MtreGAEL
Just try...
[Back to original message]
|