First of all you are testing for $ID.
if ($id) {
$sql = "SELECT * FROM deals WHERE id=$id";
The you do an else, meaning if NO $id:
} else if $lastname {
/////////////////GET DATA FROM DEALS/////////////////
$sql = "SELECT * FROM deals WHERE id=$id";
But you are still using $id in that query, not $lastname.
Then you do another else for the form. That means:
If $ID
{ do this }
else if $lastname
{ do this }
else
{do form}
So the form only shows if no $ID && no $lastname.
Do this:
If $ID
{ do this }
else if $lastname
{ do this }
do form here.
razz