Hi, why use with table error? if not use witn table are normal... can u help ???

<form method="post" action="page.php">
<table>
 <tr>
  <td>Select</td>
  <td>
   <select name="people" id="people">
    <?php if($_POST['submitted'] == true){ ?>
        <option value="<?php echo $_POST['people']; ?>" selected="selected"><?php echo $_POST['people']; ?></option>
    <?php }else{ ?>
      <option value=""> -- select -- </option>
    <?php } ?>
       <option value="" disabled="disabled"> -------- </option>
       <option value="Person 1">Person 1</option>
       <option value="Person 2">Person 2</option>
   </select>
  </td>
 </tr>
 <tr>
  <td></td>
  <td>
   <input type="submit" id="submit" name="submit" value="Submit" />
   <input type="hidden" name="submitted" id="submitted" value="true" />
  </td>
 </tr>
</table>
</form>

What is the exact error message you get?

look the image below... when i used with table

Notice: Undefined index: submitted in C:\wamp\www\Untitled-1.php on line 7

The table has nothing to do with it.

this is the one causing the error

 <?php if($_POST['submitted'] == true){ ?>

you can do something like this

<?php if(isset($_POST['submit']) && ($_POST['submitted'] == true)){ ?>

really thz for ur help @veedeoo :)

i have one more question for ask u...

if i use <?php if(isset($_POST['submit'])){ ?>

why need add ($_POST['submitted'] == true) can u explain this?

Sorry about this

 ($_POST['submitted'] == true)

It was my mistakes. It should be like this

 ($_POST['submitted'] == "true")

It should have double quotes, because it is a string and that's what I wanted to confirm . So the correct codes should be like this

    <?php if(isset($_POST['submit']) && ($_POST['submitted'] == "true")){ ?>

Now, that I have corrected my wrong response, I have to answer your question.

why need add ($_POST['submitted'] == true) can u explain this?

Normally, when we assign hidden attribute to a form input, it is for the purpose of second stage validation e.g. we want make make sure that it is not a robot filling and submitting our form. So, this

 <input type="hidden" name="submitted" id="submitted" value="true" />

can be confirmed by my proposed codes above. Another purpose is to prevent repeated form submission of the same user.

@veedeoo thz again for ur time :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.