I'd wrap the code with the php bbcode tags. Makes it easier to read.
<html>
<head>
<title> Phone List</title>
</head>
<body>
<?php
$mode = 'display';
//Connects to the database
$userName = 'REMOTE';
$passWord = 'remote123';
$systemName = 'RAA';
$dbh = db2_connect($systemName,$userName, $passWord);
if ($dbh == 0)
{
// display connection error message on failure
echo "SQL connection failed";
echo db2_conn_errormsg() . "<BR>\n";
die();
}
if ( $mode=="add")
{
Print '<h2>Add Contact</h2>
<p>
<form action=';
echo $PHP_SELF;
Print '
method=post>
<table>
<tr><td>Name:</td><td><input type="text" name="name" /></td></tr>
<tr><td>Phone:</td><td><input type="text" name="phone" /></td></tr>
<tr><td>Email:</td><td><input type="text" name="email" /></td></tr>
<tr><td colspan="2" align="center"><input type="submit" /></td></tr>
<input type=hidden name=mode value=added>
</table>
</form> <p>';
}
if ( $mode=="added")
{
$s = ("INSERT INTO tstmis.address (name, phone, email) VALUES ('$name', '$phone', '$email')");
$q = db2_exec($dbh, $s);
}
if ( $mode=="edit")
{
Print '<h2>Edit Contact</h2>
<p>
<form action=';
echo $PHP_SELF;
Print '
method=post>
<table>
<tr><td>Name:</td><td><input type="text" value="';
Print $name;
print '" name="name" /></td></tr>
<tr><td>Phone:</td><td><input type="text" value="';
Print $phone;
print '" name="phone" /></td></tr>
<tr><td>Email:</td><td><input type="text" value="';
Print $email;
print '" name="email" /></td></tr>
<tr><td colspan="2" align="center"><input type="submit" /></td></tr>
<input type=hidden name=mode value=edited>
<input type=hidden name=id value=';
Print $id;
print '>
</table>
</form> <p>';
}
if ( $mode=="edited")
{
$s = ("UPDATE tstmis.address SET name = '$name', phone = '$phone', email = '$email' WHERE id = $id");
$q = db2_exec($dbh, $s);
Print "Data Updated!<p>";
}
if ( $mode=="remove")
{
$s = ("DELETE FROM tstmis.address where id=$id");
$q = db2_exec($dbh, $s);
Print "Entry has been removed <p>";
}
$s = ("SELECT * FROM tstmis.address ORDER BY name ASC") ;
// execute the SQL
$q = db2_exec($dbh, $s);
Print "<h2>Address Book</h2><p>";
Print "<table border cellpadding=3>";
Print "<tr><th width=100>Name</th><th width=100>Phone</th><th width=200>Email</th><th width=100 colspan=2>Admin</th></tr>";
Print "<td colspan=5 align=right><a href=" .$_SERVER['PHP_SELF']. "?mode=add>Add Contact</a></td>";
while($info = db2_fetch_assoc( $q ))
{
Print "<tr><td>".$info['NAME'] . "</td> ";
Print "<td>".$info['PHONE'] . "</td> ";
Print "<td> <a href=mailto:".$info['EMAIL'] . ">" .$info['EMAIL'] . "</a></td>";
Print "<td> <a href=" .$_SERVER['PHP_SELF']. "&name=" . $info['NAME'] . "&phone=" . $info['PHONE']."&email=" . $info['EMAIL'] . "?mode=edit>Edit</a></td>";
Print "<td><a href=" .$_SERVER['PHP_SELF']. "?mode=remove>Remove</a></td></tr>";
}
Print "</table>";
?>
</body>
</html>
I did it for you. You can delete your code.