Hi me again,
sorry to be a pain. Ive been struggling with this one all day. Hope you can
understand whats happening. First my script is below. Have a look and I'll
explain at the bottom what it does so far and is failing to do
*******************************
<?php
session_start();
header("Cache-control: private"); //IE 6 Fix
include("myconn.php");
$_SESSION['pupilfield'] = trim($_POST['pupilfield']);
$_SESSION['gender'] = trim($_POST['gender']);
?>
</head>
<body>
<br><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table width="370" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="196" height="28">Type Pupil Name</td>
<td colspan="2">Select Gender</td>
</tr>
<tr>
<td>
<input name="pupilfield" type="text" value="<?php echo
$_SESSION['pupilfield'];?>" >
</td>
<td width="78">Male
<input <?php if (!(strcmp($_SESSION['gender'],"1"))) {echo "CHECKED";}
?> name="gender" type="radio" value="1">
</td>
<td width="96">Female
<input <?php if (!(strcmp($_SESSION['gender'],"2"))) {echo "CHECKED";}
?> name="gender" type="radio" value="2"></td>
</tr>
</table><br>
<?php
$res = mysql_query ("SELECT * FROM commenttype WHERE username = '$username'
AND status = 0");
if (!$res) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
?>
Filter by Category><br>
<?php
while($row1 =& mysql_fetch_array($res)) {
extract($row1);
?>
<input name="catbutton" type="submit" value="<?php echo $TypeID; ?>">
<?php echo $typedesc;
}
?>
</form>
<?php
if (isset($_POST['catbutton'])) {
$commentresults = mysql_query ("SELECT * FROM comments WHERE username =
'$username' AND status = 0 AND TypeID=".$_POST['catbutton']);
}else{
$commentresults = mysql_query ("SELECT * FROM comments WHERE username =
'$username' AND status = 0");
}
if (!$commentresults) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
?>
<br>
Select Comment
<form action="<?php echo $_SERVER['PHP_SELF']; ?> " method="post"
enctype="multipart/form-data">
<select name="selectcomm" size="5" style="WIDTH: 100%">
<?php
while($row =& mysql_fetch_array($commentresults)) {
extract($row);
?>
<option value="<?php echo $comment; ?>"><?php echo $comment; ?><br>
</option>
<?php
}
?>
</select>
<input name="addcomm" type="submit" value="Add">
<?php
$_SESSION['savedcomm'] = trim($_SESSION['savedcomm'].'
'.$_POST['selectcomm']);?>
</form>
<form name="Form1">
<p class="BodyText">
<textarea name="savedcomm" rows="5" style="WIDTH: 100%"><?php echo
$_SESSION['savedcomm'];?></textarea>
<input type="button" onClick="CopyToClipboard(),Minimize();"
value="Clipboard" />
(When clicked the browser window minimizes)
</form>
</body>
</html>
***************************************
first form
OK well first an array of buttons is created with their values coming from a
database. a textbox is filled and radiobutton selected when this form is
posted on clicking a button in the array the page is resubmitted
('PHP_SELF') resulting in sessions being created from the text field and
radio buttons. The values of the textfield and radiouttons are set to the
sessions so that the values persist on the page during 'PHP_SELF'.
Problem arrises on the second form where values from a list are posted and
copied into the final textfield at the bottom. During this second form
posting the values in the textbox and radio buttons are lost. I want them to
remain until the sessions are made false. can anyone help.
I know its alot of code to untangle but Im really stuck on this one
Ian 6 4605
Ian Davies wrote: Hi me again, sorry to be a pain. Ive been struggling with this one all day. Hope you can understand whats happening. First my script is below. Have a look and I'll explain at the bottom what it does so far and is failing to do
<code sniped>
first form OK well first an array of buttons is created with their values coming from a database. a textbox is filled and radiobutton selected when this form is posted on clicking a button in the array the page is resubmitted ('PHP_SELF') resulting in sessions being created from the text field and radio buttons. The values of the textfield and radiouttons are set to the sessions so that the values persist on the page during 'PHP_SELF'.
Problem arrises on the second form where values from a list are posted and copied into the final textfield at the bottom. During this second form posting the values in the textbox and radio buttons are lost. I want them to remain until the sessions are made false. can anyone help.
I know its alot of code to untangle but Im really stuck on this one
Ian
Ian,
I haven't looked at your code in detail - but I think your problem is how the
data is being submitted.
When you submit a form, only data from that specific form is in the $_POST (or
$_GET) value. Data from other forms on the page will not be submitted.
If you want to keep data from the first form after submitting the second one,
you have a couple of choices. You can put the first form data in the session
(my favorite). You can also store it in hidden fields in the second form (also
works well).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attglobal.net
==================
hi jerry
the data is in a session, and it retains itself during the first form post.
however I cannot get it to remain when the second form posts, even though
the sessions are still true and the textbox and radiobuttons values are are
still set to the session. I think it has to do with the second form somehow.
it seems that it is influencing the textbox and radiobutton's values. but i
cant work out why
ian
"Jerry Stuckle" <js*******@attglobal.net> wrote in message
news:d4******************************@comcast.com. .. Ian Davies wrote: Hi me again, sorry to be a pain. Ive been struggling with this one all day. Hope you
can understand whats happening. First my script is below. Have a look and
I'll explain at the bottom what it does so far and is failing to do
<code sniped>
first form OK well first an array of buttons is created with their values coming
from a database. a textbox is filled and radiobutton selected when this form is posted on clicking a button in the array the page is resubmitted ('PHP_SELF') resulting in sessions being created from the text field and radio buttons. The values of the textfield and radiouttons are set to
the sessions so that the values persist on the page during 'PHP_SELF'.
Problem arrises on the second form where values from a list are posted
and copied into the final textfield at the bottom. During this second form posting the values in the textbox and radio buttons are lost. I want
them to remain until the sessions are made false. can anyone help.
I know its alot of code to untangle but Im really stuck on this one
Ian
Ian,
I haven't looked at your code in detail - but I think your problem is how
the data is being submitted.
When you submit a form, only data from that specific form is in the $_POST
(or $_GET) value. Data from other forms on the page will not be submitted.
If you want to keep data from the first form after submitting the second
one, you have a couple of choices. You can put the first form data in the
session (my favorite). You can also store it in hidden fields in the second form
(also works well).
-- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. js*******@attglobal.net ==================
Ian Davies wrote: hi jerry the data is in a session, and it retains itself during the first form post. however I cannot get it to remain when the second form posts, even though the sessions are still true and the textbox and radiobuttons values are are still set to the session. I think it has to do with the second form somehow. it seems that it is influencing the textbox and radiobutton's values. but i cant work out why ian
I suspect the problem is this:
$_SESSION['pupilfield'] = trim($_POST['pupilfield']);
$_SESSION['gender'] = trim($_POST['gender']);
After the second form, this $_POST values are non-existent, so null, and
hence $_SESSION[key] get's set to null.
Use:
$_SESSION[key] = (isset($_POST[key])) ? trim($_POST[key]) : $_SESSION[key];
Grtz,
--
Rik Wasmus
Your a saviour Rik cheers
Works a treat.
out of interest what is the script doing? I cant work it out
Ian
"Rik" <lu************@hotmail.com> wrote in message
news:3b***************************@news2.tudelft.n l... Ian Davies wrote: hi jerry the data is in a session, and it retains itself during the first form post. however I cannot get it to remain when the second form posts, even though the sessions are still true and the textbox and radiobuttons values are are still set to the session. I think it has to do with the second form somehow. it seems that it is influencing the textbox and radiobutton's values. but i cant work out why ian I suspect the problem is this: $_SESSION['pupilfield'] = trim($_POST['pupilfield']); $_SESSION['gender'] = trim($_POST['gender']);
After the second form, this $_POST values are non-existent, so null, and hence $_SESSION[key] get's set to null.
Use: $_SESSION[key] = (isset($_POST[key])) ? trim($_POST[key]) :
$_SESSION[key]; Grtz, -- Rik Wasmus
Ian Davies wrote: $_SESSION[key] = (isset($_POST[key])) ? trim($_POST[key]) : $_SESSION[key]; Your a saviour Rik cheers Works a treat. out of interest what is the script doing? I cant work it out
Search www.php.net for ternary operator: http://nl2.php.net/manual/en/languag...comparison.php
Actually, it does the following:
if(isset($_POST[key]){ //checks wether a new $_POST value with the specific
key exists
$_SESSION[key] = trim($_POST[key]); //sets the session value to the
posted value
} else {
$_SESSION[key] = $_SESSION[key]; //keep the session variable the same as
it was
}
The ternary operator just saves a lot of lines in the code while doing
simple checks.
Grtz,
--
Rik Wasmus
thanks
will make a note of that one
ian
"Rik" <lu************@hotmail.com> wrote in message
news:cf***************************@news2.tudelft.n l... Ian Davies wrote: $_SESSION[key] = (isset($_POST[key])) ? trim($_POST[key]) : $_SESSION[key]; Your a saviour Rik cheers Works a treat. out of interest what is the script doing? I cant work it out
Search www.php.net for ternary operator: http://nl2.php.net/manual/en/languag...comparison.php
Actually, it does the following:
if(isset($_POST[key]){ //checks wether a new $_POST value with the
specific key exists $_SESSION[key] = trim($_POST[key]); //sets the session value to the posted value } else { $_SESSION[key] = $_SESSION[key]; //keep the session variable the same
as it was }
The ternary operator just saves a lot of lines in the code while doing simple checks.
Grtz, -- Rik Wasmus
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: J P Singh |
last post by:
I have simple form where user enter the search criteria and the form is
posted back to itself and runs a query based on the values that are entered.
Everything is expect the values that the user...
|
by: Bill Cohagan |
last post by:
In my app I'm validating an XML file against an XSD which contains several
attribute default value specifications. I'm performing the validation via an
xml document load() using a...
|
by: Penny Bond |
last post by:
Hi,
Any help or suggestions on this one would be gratefully appreciated:
I have 2 aspx pages one is called 'Query' and the other 'Details'. Query
page has a number of text boxes and drop...
|
by: the friendly display name |
last post by:
Hello.
If a convert a string (string number = "24.45") into a double, using the
Convert class ((double doublenumber = Convert.ToDouble(number)), the result
will have the value 2445.
How do I...
|
by: TomJ |
last post by:
Hey guys, I am attempting to use the following example:
'Session("Name")' to maintain a value between moduleA and moduleB.
ModuleB captures the Session("Name") to be used by moduleA throughout
its...
|
by: Sonasang |
last post by:
Hi,
I am creating a web page using ASP and Javascript.
When submit button is clicked , It will search for the values in the input given(in the input box).
How to retain the values in the...
|
by: nimjerry |
last post by:
i am using db2 udb V 9 on aix 5.3 and in db2diag.log alwas has this error occurr
below is sample message
2008-03-03-09.45.34.366406+420 I306667A443 LEVEL: Warning
PID : 835622 ...
|
by: raaman rai |
last post by:
Hi Fellas, i need to understand how to retain the submtted form values during an Edit/Update operation.
When i add the information from a form, i retain the form values in the following way incase...
|
by: pankajsingh5k |
last post by:
Hi guys,
These question is for all the experts...
Please help me before my brain explodes
The problem is again with the formview control..
I have a formview and i have to use it that...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |