Q:

$row error keeps saying undefined? I cant find the mistake

<?php
$con = mysql_connect("localhost","root");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("database", $con);
if(isset($_GET['id']))
{
$id = $_GET['id'];
$result = mysql_query("SELECT * FROM pleasework WHERE ID= $_GET[id]");
$row = mysql_fetch_array($result);
}
if(isset($_POST['New']))
{
    $New= $_POST['New'];
    $id= $_POST['id'];
    $sql = "UPDATE pleasework SET Name = '$New' WHERE id='$id'";
    $result = mysql_query($sql) or die("could not update" . mysql_error);

}

?>

 <form action="edit.php" id="form2" method="post" name="form2">
<img id="close1" src="X.png" width="25" height="25" onclick ="div_hide1()">
<h2><font size="6">Please change existing data</font></h2>
<hr>

     <font color="yellow">Change Name to: </font><input type="text" name="New" value="<?php echo $row['Name'];?>"/><br><br>
      <font color="yellow"> Change Cause to: </font> <input type="text" name="New1" value="<?php echo $row['Cause'];?>"/><br><br>
 <font color="yellow">Change Symptom to:  </font><input type="text" name="New2" value="<?php echo $row['Symptom'];?>"/><br><br>
      <font color="yellow"> Change Gene_affected to:  </font><input type="text" name="New3"value="<?php echo $row['Gene_affected'];?>" /><br><br>
      <input type="hidden" name="id" value="<?php echo $row['id'];?>"/>
    <input type="submit" onclick="clicked(event)" />
</form>

<?php
if(isset($_POST['submit'])){
    $u = "(UPDATE pleasework SET Name='$_POST[New]' , '$_POST[New1]' ,     '$_POST[New2]' , '$_POST[New3]'  WHERE ID=$_POST[id]";
    mysql_query($u) or die(mysql_error());

    echo"User has been modified";
    header("Location: databse.php");
} 

?>

This error keeps popping up whenever I click submit on my edit.php file. I thought I already declared $row?
The same error goes on for all the input types...
<br /><b>Notice</b>:  Undefined variable: row in <b>E:\XAMPP\htdocs\database\edit.php</b> on line <b>34</b><br />

A:

try this:
 <?php
    $submit=isset($_POST['submit']);
    $id=isset($_POST['id']);

    if($submit)
    {
        $New= $_POST['New'];
        $id= $_POST['id'];
      //insert db configurations
        $sql = "UPDATE pleasework SET Name = '$New' WHERE id='$id'";
        $result = mysql_query($sql) or die("could not update" . mysql_error);
    }
    else if($id)
    {
    $id= $_POST['id'];
      //insert db configurations
    $result = mysql_query("SELECT * FROM pleasework WHERE ID= $_GET[id]");
    $row = mysql_fetch_array($result);
    ?>

     <form action="edit.php" id="form2" method="post" name="form2">
    <img id="close1" src="X.png" width="25" height="25" onclick ="div_hide1()">
    <h2><font size="6">Please change existing data</font></h2>
    <hr>

         <font color="yellow">Change Name to: </font><input type="text" name="New" value="<?php echo $row['Name'];?>"/><br><br>
          <font color="yellow"> Change Cause to: </font> <input type="text" name="New1" value="<?php echo $row['Cause'];?>"/><br><br>
     <font color="yellow">Change Symptom to:  </font><input type="text" name="New2" value="<?php echo $row['Symptom'];?>"/><br><br>
          <font color="yellow"> Change Gene_affected to:  </font><input type="text" name="New3"value="<?php echo $row['Gene_affected'];?>" /><br><br>
          <input type="hidden" name="id" value="<?php echo $row['id'];?>"/>
        <input type="submit" onclick="clicked(event)" />
    </form>

    <?php
    }
    else
    {
    echo"anything";
    }
    ?>

