Kingofkolt thanks for the suggestion.
It is interesting how others that comments on this question only say it
"cannot" be done because ....
While knowledgeable people like yourself offer creative thoughts on the
problem.
The problem is the user enters data into the form which must be reset, yes I
know about the reset command in html.
When the user returns to the form, the initial values are set by session
data (data and calculations) from a number of pages past the form.
I was looking for a means of resetting both with one button. The reason I
left the onClick to stimulate thought on how to reset both users text &
session initiated values with one button which could include a subroutine.
To answer a few of the questions:
2. Are you looking for a button that will make the text field blank?
Yes
or a button that will reset the text field to its original value
No, the initial values are set by sessions after returning to the form;
sessions must also be reset. Initially, the initial value=""
I prefer not to use JavaScript for security reason; part of the form
contains credit card numbers. I only use JavaScript for validation.
3. The values submitted by the form are not stored in the $_SESSION
variable. Access them using $_POST.
Actually, the initial values are stored in sessions variables after the
user returns to the form.
As far as the nice little manual on PHP, I searched it and could not find
any help on resetting html form text and PHP-session initiated values in a
form. I would be interested if the others can point to a section that
covers both.
I am also new the this language. I have only written about 150 pages for
this website utilizing HTML, JavaScript, PHP and MySql.
I am still learning.
Thanks again for taking the time to send a helpful suggestion. It is people
like you who help us to learn. The others just criticize.
Ken
"kingofkolt" <je**********@comcast.net> wrote in message
news:7bcVc.191440$eM2.188414@attbi_s51...
"Sebastian Lauwers" <da***********@nospam.9online.fr> wrote in message
news:41***********************@news.free.fr... kingofkolt wrote:
Oh boy...
A few pointers:
1. PHP is server-side. That means PHP does not act based on an onClick="..." event handler. If you want $_SESSION variables to be cleared, the user will have to send a whole new request to the server, because client-side actions do not activate PHP scripts.
2. Are you looking for a button that will make the text field blank,
or a button that will reset the text field to its original value? Neither
of these are PHP-related. If you want to make the text field blank, use
JavaScript. If you want to reset it to it's original value, use <input
type="reset" value="Reset">. You don't need an onClick="..." event
handler for that.
3. The values submitted by the form are not stored in the $_SESSION
variable. Access them using $_POST.
4. If you want to reset the $_SESSION array by clikcing on a nice little
button use this:
<?php
if (!isset ($_POST['reset'])) {
echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">
<input type="submit" value="Reset the $_SESSION array"
name="reset" />
</form>';
}
else {
$_SESSION = array();
echo 'Happy?';
}
?>
BTW, there's this nice little manual at PHP.net that you may want to
read.
Yeah, indeed, print it out, and read one chapter every night before
going to bed. Honnestly, you could be a guru for PHP4/5 when PHP XXIII
will be out and running...
- JP
Best regards,
Sebastian
--
The most likely way for the world to be destroyed,
most experts agree, is by accident.
That's where we come in; we're computer professionals.
We cause accidents.
--Nathaniel Borenstein
To me it sounded more like he wanted to clear the form than the $_SESSION
variable, and tried to go about doing that by clearing the $_SESSION
variable, which isn't necessary. And about the sarcasm, it seems there are
a lot of people lately asking how to do something with PHP that can clearly
only be achieved using client-side scripts (Ex: trying to run the
reset_form() PHP function using onClick="...").