I am working on a form for a survey. It is very simple as it only has three radio buttons. After the form is submitted, I have another PHP page handling the form. I am using isset to check to see if each one was ticked. If one was not ticked, I want to display a message asking the user to answer each one. On the other hand, I also want to display a message how can I pass a message once the form is successfully completed. I know how to easily do this in JavaScript but no in PHP.

Anyone care to help me out? Below is the code I have:

This is where I want to display the message. The page that contains this is only a PHP page and not an HTML page. Thanks to anyone that takes a look at this.

<span name="message">&nbsp;</span>

PHP Code:

session_start(); 
<?php



if(!isset($_POST['whereBuyBooks']) ||
   !isset(
$_POST['rent']) ||
   !isset(
$_POST['usefulness'])){
       
     
//How do I get this on the survey page??
    
$message 'Please answer each question';
  }


//Grabs data from form
$whereBuyBooks $_POST['whereBuyBooks'];
$rent $_POST['rent'];
$usefulness $_POST['usefulness'];

//Grabs current time
$curtime date("Y-m-d H:i:s",time()); 

// Formats data before writing to file
$data =  'New survery taken on: ' .$curtime."\n";
$data .= 'Where students buy most books: ' .$whereBuyBooks "\n";
$data .= 'Do you rent texbooks: ' .$rent"\n";
$data .= 'How useful do you find our site: ' .$usefulness"\n\n\n\n";
              
        
$filename 'survey.txt';

file_put_contents($filename$dataFILE_APPEND);
       
//How do I get this on the survey page??
$message 'Thank you for completing our survey';
        
 
header("Location: index.php"); 
        
        
?>