Hi dears

I have a little question about the best logical way to display error messages when a user forgot to fill in a form field. I am trying to avoid the awful 'echo-blank-page' solution here. I have been trying a few things instinctively, but I think that I need a little boost here from more knowledgeable people than me.

Here we go (that's my actual code, in progress, and that's as far as I can go by myself):
PHP Code:
//if the member has submitted the text to be edited yet.

$error='';

if ( isset(
$_POST['edit']) ) {
    
    
//just a patanoid check.
    
if ( $_POST['userID'] != $_SESSION['userID'] ) {
        
$auth->logout();
    }else{
    
    
//check that the fields are not empty
    
        
if ( ($_POST['title']='') or ($_POST['text']!='') ) {
            
$error .= 'Please make sure that you have filled in all the fields.';
            
$errorCheck true;
        }else{
            
$title=$_POST['title'];
            
$text=$_POST['text'];
            
$textID=$_POST['textID'];
            
$userID=$_SESSION['userID'];
    
            
$sql =
             
"UPDATE userstexts 
             SET
             textTitle = '
$title'
             , textText = '
$text'
             , newAdmin = 1
             WHERE
             textID = 
$textID
             AND userID = 
$userID";
 
             
$db->query($sql);

            
header("Location:userCP_index.php"); 
            exit;
        }
    }


//if the member has not submitted the text to be edited yet.
if ( !isset($_POST['edit']) ) {
    
    
//**********checks that both textID and userID are set, if not, log out!**********
        
    
if ( (!isset($_GET['textID'])) or (!isset($_SESSION['userID'])) ) {
        
$auth->logout();
    }else{
        
$textID=$_GET['textID'];
        
$userID=$_SESSION['userID'];
    }

    
$sql =
    
"SELECT textID
    , textTitle
    , textText 
    FROM userstexts 
    WHERE textID = 
$textID 
    AND userID = 
$userID
    ORDER BY textID DESC"

        
    
$result=$db->query($sql);
        
    
//**********the users must have texts to edit**********
    //**********if he tries to access this page without any texts to edit,**********
    //**********he gets logged out.**********
        
    
if ( $result->size() == ) {
        
$auth->logout();
    }
        
    
$row $result->fetch(); 
and here is the form (in the same page) with the error message to display:
PHP Code:
            <p><?=$error?></p>
            
            
            
            <form action="<?=$_SERVER['PHP_SELF']?>" method="POST">
    
            <div class="quickReply">
                <p class="centre" style="text-align:centre;">
                <input type="text" name="title" id="title" value="<?=$row['textTitle']?>" />
                </p>
                <p class="centre" style="text-align:centre;">
                <textarea rows="10" cols="30" name="text" id="text"><?=$row['textText']?></textarea>
                </p>
                <input type="hidden" name="textID" value="<?=$textID?>" />
                <input type="hidden" name="userID" value="<?=$userID?>" />
                <p class="centre" style="text-align:centre;">
                <input type="submit" name="edit" value="edit" />
            </div>
        
            </form>
thanks in advance for your help