I am currently working on a few simple PHP form examples and am coming across a lot of errors. I am very new to PHP so errors are usually expected but I am very curious as to how I can overcome some of these errors. On form #1 I am running into a 'Notice: Undefined Index' error. I know that the solution for this is usually isset() but I don't know how to implement it in this part of my code that I will display below.
<p class="label">Reason for Contacting Us*</p>
<select class="" name="dropDwn" id="dropdown">
<option value="dummy" disabled selected>Select One...</option>
<option value="Server Issues" <?php if($_POST['dropDwn'] == "Server Issues")
echo "Server Issues"; ?>>Server Issues</option>
<option value="Domain Problems" <?php if($_POST['dropDwn'] == "Domain
Problems") echo "Domain Problems"; ?>>Domain Problems</option>
<option value="Website Creation" <?php if($_POST['dropDwn'] == "Website
Creation") echo "Website Creation"; ?>>Website Creation</option>
<option value="Billing Issues" <?php if($_POST['dropDwn'] == "Billing
Issues") echo "Billing Issues"; ?>>Billing Issues</option>
</select>
<span class="error-messages"><?php echo $dropdownErrMsg;?></span>
</p>
Here is a link to the form above: http://mujomusic.net/WDV341/FormProject/index.php
P.S. The error shows up on when you click on the dropdown!
The error on form #2 seems a lot more complex to me... the error being thrown is 'in_array() expects parameter 2 to be array, null given' and also 'Undefined Variable' which is one I am not at all familiar with. Here is the code(I am going to display just one checkbox set instead of all four):
<p><b>Tuesday/Thursday 10:10am-Noon</b></p>
<span class="error"><?php echo $optFourErr; //place error message on form ?
></span>
<p>
<label for="">Worst</label>
<input type="checkbox" name="option4[]" value="Worst" <?=
(in_array('Worst', $inFour)) ? 'checked' : ''; ?>>
<label for="">Decent</label>
<input type="checkbox" name="option4[]" value="Decent" <?=
(in_array('Decent', $inFour)) ? 'checked' : ''; ?>>
<label for="">Best</label>
<input type="checkbox" name="option4[]" value="Best" <?=
(in_array('Best', $inFour)) ? 'checked' : ''; ?>>
</p>
Here is the link to Form #2: http://mujomusic.net/WDV341/ClassProject/index.php
I am just looking for some possible solutions to these errors so I can advance my PHP skills! Any help is well appreciated!