The follweing code IS working (it sends the data to the database). But I'm getting the "Notice: undefined index" as soon as I open the page and also it creates a null line (I mean, onde null value for each field) in the database. If I fill in the fields and submit it will work and they will be saved in the database alright, though. I think I need a code that will tell "submit" not to send data to the database it empty. What code is that? i'm not familiar with mysqli.

```
<?php
$con=mysqli_connect("localhost","root","","activitytest1");

if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$sql="INSERT INTO activitytest1 (type, description, author, outcome, pre, whileact, postact, path, books, grouping, time)
VALUES
('$_POST[type]','$_POST[description]','$_POST[author]','$_POST[outcome]','$_POST[pre]','$_POST[whileact]','$_POST[postact]','$_POST[path]','$_POST[books]','$_POST[grouping]','$_POST[time]')";

if (!mysqli_query($con,$sql))
  {
  die('Error: ' . mysqli_error($con));
  }
$result = mysqli_query($con,"SELECT * FROM activitytest1");

while($row = mysqli_fetch_array($result))
  {
  echo "<br/>

<table width='909' border='1' align='center' cellpadding='5' cellspacing='0'>
  <tr>
    <td width='125'>" . $row['type'] .  "</th>
    <td width='680'>" . $row['description'] .  "</th>
    <td width='120'>" . $row['author'] .  "</th>
  </tr></table> <br/>" . $row['pre'] .  "<br/>" . $row['whileact'] .  "<br/>" . $row['postact'] .  "<br/>" . $row['outcome'] .  "<br/>" . $row['path'] . "<br/>" . $row['books'] .  "<br/>" . $row['grouping'] .  "<br/>" . $row['time'] . "<hr size='1'/>";
  }

mysqli_close($con);
?>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test 1</title>
</head>
<body>

<br>
<table width="909" border="1" align="center" cellpadding="5" cellspacing="0">
  <tr>
    <th width="125" scope="col">Type</th>
    <th width="680" scope="col">Description</th>
    <th width="120" scope="col">Author</th>
  </tr></table>
  <br>
<form action="index.php" method="POST">

<table width="909" border="1" align="center" cellpadding="5" cellspacing="0">
     <td width="125"><label>

     </label>
       <select name="type" id="type" onChange="display(this,'Task','Semi-task','Practice','Exercise','Lead-in');">
         <option value="Unselected" selected="selected">Choose one:</option>
         <option value="Task">Task</option>
         <option value="Semi-task">Semi-task</option>
         <option value="Practice">Practice</option>
         <option value="Exercise">Exercise</option>
         <option value="Lead-in">Lead-in</option>
         <option value="Game">Game</option>
         <option value="Video">Video</option>
         <option value="Song">Song</option>
         <option value="Mimio">Mimio</option>
         <option value="Other">Other</option>
       </select></td>
    <td width="680"><div id="Semi-task" style="display: none;">
      Pre:<br>
    </div>
        <div id="Exercise"  style="display: none;">whileact:</div>
        <br>
        <div id="Practice" style="display: none;">
      Post:<br>
      <br>
       </div>
        <div id="Task"  style="display: none;"> Outcome: <br />
        <textarea name="description" cols="70" rows="2"></textarea>
            <br />
        </div>
        <div id="Lead-in" style="display: none;">
      Link/Path:<br>
      <br>
       </div></td>
    <td width="120"><input name="author" type="text" size="12" maxlength="25" /></td>
  </tr>
     <tr>
       <td colspan="3">      <textarea name="pre" id="Pre" cols="45" rows="5"></textarea>
                       <br /><textarea name="whileact" id="whileact" cols="45" rows="5"></textarea>
                       <br /><textarea name="postact" id="Post" cols="45" rows="5"></textarea>
                       <br /><textarea name="outcome" id="Outcome" cols="45" rows="5"></textarea>
                       <br /><input type="text" name="path" id="Path" />
                       <br /><input type="text" name="books" id="Books" />
                       <br /><input type="text" name="grouping" id="Grouping" />
                       <br /><input type="text" name="time" id="Time" />
                       </td>
     </tr>
    <tr>
       <td colspan="3"><input type="submit" name="submit" value="Comment" /></td>
     </tr>
</table>
</form>

</body>
</html>

```