Error below: I'm pretty much trying to see what the user chose from the checkboxes.
Notice: Undefined variable: ch1 in /Applications/XAMPP/xamppfiles/htdocs/ProjectOne/index.php on line 42 ch1
HTML CODE :
<form action='submit.php' method="GET">
<div id="self">
<input type='text' name='Name' value='Name' />
<br>
<input type='text' name='Cwid' value='CWID' />
<br>
</div>
<div id='gender'>
<strong>Gender:</strong><input type="radio" name="sex" value="male"checked>Male
Or
<input type="radio" name="sex" value="female">Female
<br>
<div>
<div id='class'>
<strong>Class:</strong> <select name='class'>
<option value='Freshman'> Freshman </option>
<option value='Sophomore'> Sophomore </option>
<option value='Junior'> Junior </option>
<option value='Senior'> Senior </option>
</select>
</div>
<br>
<div id='pref'>
<strong>Student Preferences</strong>
<br>
<!-- line 42 -->
<input type="checkbox" name="ch1" value="ch133" /> <?PHP echo $ch1; ?> ch1 <br />
<input type="checkbox" name="ch2" value="Laundry on Premise" /> Laundry on Premise<br />
<input type="checkbox" name="ch3" value="Fully Equipped Kitchen" /> Fully Equipped Kichen<br />
</div>
<div id='submit'><input type="submit" name='submit' value="Submit" /> </div>
</form>
PHP CODE BELOW :
<?php
$ch1 = 'unchecked';
$ch2 = 'unchecked';
$ch3 = 'unchecked';
if(isset($_GET['submit']))
{
$name = $_GET['Name'];
$cwid = $_GET['Cwid'];
$sex = $_GET['sex'];
$class = $_GET['class'];
$ch1 = $_GET['ch1'];
$ch2 = $_GET['ch2'];
$ch3 = $_GET['ch3'];
if (isset($ch1)) {
$ch1 = $_GET['ch1'];
if ($ch1 == 'ch1') {
$ch1 = 'checked';
}
}
}
?>