Undefined index error

Is there a way to correct this as I am getting an error each time in the logs.


[02-Jul-2014 01:28:24 America/Chicago] PHP Notice:  Undefined index: find-us in /home/public_html/app.php on line 526



<option value="(Select one)" selected>---Select Below---</option>
<option value="How did you find us?" selected>How did you find us?</option>

<option value="Yahoo/Bing search" <?= ($_POST['subject'] == "1")? "selected":"";?>>Yahoo search</option>
<option value="Google search" <?= ($_POST['subject'] == "2")? "selected":"";?>>Google search</option>
<option value="AOL search" <?= ($_POST['subject'] == "3")? "selected":"";?>>AOL search</option>
<option value="Other Search Engine" <?= ($_POST['subject'] == "4")? "selected":"";?>>Other Search Engine</option>
<option value="Twitter" <?= ($_POST['subject'] == "5")? "selected":"";?>>Twitter</option>
<option value="Facebook" <?= ($_POST['subject'] == "6")? "selected":"";?>>Facebook</option>

Does this help at all.

<option value="(Select one)" selected="selected">---Select Below---</option>
<option value="How did you find us?" selected="selected">How did you find us?</option>

<option value="Yahoo/Bing search" <?php echo (isset($_POST['subject']) && $_POST['subject'] == "1" ? " selected=\\"selected\\"" :'');?>>Yahoo search</option>
<option value="Google search" <?php echo (isset($_POST['subject']) && $_POST['subject'] == "2" ? " selected=\\"selected\\"" :'');?>>Google search</option>
<option value="AOL search" <?php echo (isset($_POST['subject']) && $_POST['subject'] == "3" ? " selected=\\"selected\\"" :'');?>>AOL search</option>
<option value="Other Search Engine" <?php echo (isset($_POST['subject']) && $_POST['subject'] == "4" ? " selected=\\"selected\\"" :'');?>>Other Search Engine</option>
<option value="Twitter" <?php echo (isset($_POST['subject']) && $_POST['subject'] == "5" ? " selected=\\"selected\\"" :'');?>>Twitter</option>
<option value="Facebook" <?php echo (isset($_POST['subject']) && $_POST['subject'] == "6" ? " selected=\\"selected\\"" :'');?>>Facebook</option>

Nothing in that code references a find-us key. Getting rid of the error is as simple as using isset to check for it as demonstrated in this code.

change it to this


<select name="find-us" id="find-us">
<option value="(Select one)" selected>---Select Below---</option>
<option value="How did you find us?" selected>How did you find us?</option>

<option value="Yahoo/Bing search" <?= ($_POST['subject'] == "1")? "selected":"";?>>Yahoo search</option>
<option value="Google search" <?= ($_POST['subject'] == "2")? "selected":"";?>>Google search</option> 
<option value="AOL search" <?= ($_POST['subject'] == "3")? "selected":"";?>>AOL search</option>
<option value="Other Search Engine" <?= ($_POST['subject'] == "4")? "selected":"";?>>Other Search Engine</option>
<option value="Twitter" <?= ($_POST['subject'] == "5")? "selected":"";?>>Twitter</option>
<option value="Facebook" <?= ($_POST['subject'] == "6")? "selected":"";?>>Facebook</option>
</select>


undefined index is looking for the posted find-us,you should put attribute name in you select

<select name=“find-us” id=“find-us”>

hope this will help :slight_smile: