0

I have one form in that i select state and city after i click search button ,in test.php i got value but i refresh the test.php page means i am not getting that time,i am getting error like this

Notice: Undefined index: state in C:\xampp\htdocs\Kanniyappan\transitoak\test.php on line 3

Notice: Undefined index: area in C:\xampp\htdocs\Kanniyappan\transitoak\test.php on line 4

test.php

<?php
echo $_POST['state']."<br>";
echo $_POST['area'];
?>
<form method="POST" id="basicForm"  class="form-horizontal form-bordered" action="test.php">
                <div class="col-md-4">
                   <select onchange="getCity(this.value);" class="form-control intro-form-fixer" required="" id="state" name="state" data-msg-required="Please enter your State" value="" aria-required="true">
                        <option value="">SELECT STATE</option>
                        <?php
                        include("dbconfig.php");
                        $sql = mysql_query("SELECT * FROM state_list");
                        while($row=mysql_fetch_assoc($sql)){
                        ?>
                        <option value="<?php echo $row['id'];?>"><?php echo $row['state'];?></option>
                    <?php } ?>
                  </select>&nbsp;&nbsp;<span id="state_err"></span>

                </div>
                <div class="col-md-4">
                  <select class="form-control intro-form-fixer" autocomplete="off" name="area" id="area" style="width:100%;">
                     <option value="">Select Area</option>
                     <option value="1">Tn</option>
                     <option value="2">k</option>
                   </select>
                </div>
                <div class="col-md-2">
                <!--<button type="submit" id="btn-submit" class="btn btn-success">SEARCH</button> -->
                 <input type="submit" class="btn btn-primary" id="btn-submit" name="submit" value="SEARCH">
                </div>
                </form>
Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
Kani R
  • 193
  • 2
  • 14
  • 1
    Do yourself a favor, simply place a `print_r($_POST)` or `var_dump($_POST)` in the PHP page which receives the form submission. Fill out your form, submit and look closely at the data printed to the screen. Familiarize yourself with how form data is posted to scripts, including what gets passed and what doesn't. – Jay Blanchard Oct 11 '16 at 13:23

1 Answers1

0

The Undefined index Notice, means that the index 'state' && 'area' does not exist in your $_POST array. This usaually means the data from the form isnt being sent properly. Try doing a var_dump($_POST); see if that brings up any data and check if that names are there