Posted: Fri Jun 01, 2007 8:23 pm
Hi,
I'm back. I'm finally starting to create my form and table. Before I program everything, I'm running some test data. I was able to successfully set the check to 1 and maintain the choices selected.
But, first, when I run the script for the first time, the first thing that displays on the screen is my message "No Good". Then, the form appears. Once, I make my selections, then the script run fine.
I'm not understanding why the "No Good" is appearing. There is probably something wrong with the syntax but I can't quite see it.
Can you take a look? Thanks for the help.
This is how the screen appears when the script is first called.
No good.
[]Abuse
[]Aggression
[]Allegations of Abuse/Neglect
This is my script.
I'm back. I'm finally starting to create my form and table. Before I program everything, I'm running some test data. I was able to successfully set the check to 1 and maintain the choices selected.
But, first, when I run the script for the first time, the first thing that displays on the screen is my message "No Good". Then, the form appears. Once, I make my selections, then the script run fine.
I'm not understanding why the "No Good" is appearing. There is probably something wrong with the syntax but I can't quite see it.
Can you take a look? Thanks for the help.
This is how the screen appears when the script is first called.
No good.
[]Abuse
[]Aggression
[]Allegations of Abuse/Neglect
This is my script.
Code: Select all
<?php
require_once ('mysql_connect.php');
if (isset($_POST['submitted'])) {
//validate form data
if (isset($_POST['beh_abuse'])) {
$_SESSION['beh_abuse'] = 1;
} else {
$_SESSION['beh_abuse'] = 0;
}
if (isset($_POST['beh_aggr'])) {
$_SESSION['beh_aggr'] = 1;
} else {
$_SESSION['beh_aggr'] = 0;
}
if (isset($_POST['beh_alleg'])) {
$_SESSION['beh_alleg'] = 1;
} else {
$_SESSION['beh_alleg'] = 0;
}
echo "$_SESSION[beh_abuse]<br>";
echo "$_SESSION[beh_aggr]<br>";
echo "$_SESSION[beh_alleg]<br>";
}
else {
echo 'No good.';
}
?>
<form action="behavior_form_test.php" method="post">
<table>
<tr><td valign="top">
<?php
if(isset($_SESSION['beh_abuse']) && $_SESSION['beh_abuse'] == '1')
echo '<input type="checkbox" name="beh_abuse" id="beh_abuse" value="abuse" checked> Abuse ';
else
echo '<input type="checkbox" name="beh_abuse" id="beh_abuse" value="abuse">Abuse ';
?>
</td></tr>
<tr><td valign="top">
<?php
if(isset($_SESSION['beh_aggr']) && $_SESSION['beh_aggr'] == '1')
echo '<input type="checkbox" name="beh_aggr" value="beh_aggr" checked> Agression ';
else
echo '<input type="checkbox" name="beh_aggr" value="beh_aggr">Aggression ';
?>
</td></tr>
<tr><td valign="top">
<?php
if(isset($_SESSION['beh_alleg']) && $_SESSION['beh_alleg'] == '1')
echo '<input type="checkbox" name="beh_alleg" value="beh_alleg" checked> Abuse ';
else
echo '<input type="checkbox" name="beh_alleg" value="beh_alleg">Allegations of Abuse/Neglect ';
?>
</td></tr>
</table>
<input type="submit" name="btnSubmit" id="btnSubmit" value="Submit" class="btn" >
<input type="hidden" name="submitted" value="TRUE" />
</form>