|
Posted by Ian Davies on 05/30/06 01:08
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
Navigation:
[Reply to this message]
|