title: how to display the result after the submit php form
body: <p>how to display the result after submit the form </p>
  
  <p>i want a display result after submit the form for print</p>
  
  <p>example 1st im filling the form submit the result after the submit i want a screen to display same result
  <a href="http://www.tizag.com/phpT/examples/formexample.php" rel="nofollow">http://www.tizag.com/phpT/examples/formexample.php</a></p>
  
  <p>how can i do this 
  please help me to fix this issue.</p>
  
  <p>php form code</p>
  
  <pre><code>&lt;?php
       function renderForm($grn, $name, $rollno, $class, $fees, $date, $reference, $error)
       {
       ?&gt;
       &lt;?php 
       if ($error != '')
       {
       echo '&lt;div style="padding:4px; border:1px solid red; color:red;"&gt;'.$error.'&lt;/div&gt;';
       }
       ?&gt; 
       &lt;form action="" method="post"&gt;
       &lt;div&gt;
         &lt;p&gt;&lt;span class="style9"&gt;&lt;strong&gt;G.R.N No:&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;  *&lt;/strong&gt;
           &lt;input name="grn" type="text" id="grn" value="&lt;?php echo $grn; ?&gt;" size="50" /&gt;
         &lt;/p&gt;
         &lt;p&gt;&lt;span class="style9"&gt;&lt;strong&gt;Name:&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;  *&lt;/strong&gt;
           &lt;input name="name" type="text" id="name" value="&lt;?php echo $name; ?&gt;" size="50" /&gt;
         &lt;/p&gt;
  
         &lt;p&gt;&lt;span class="style9"&gt;&lt;strong&gt;Roll No :&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;  *&lt;/strong&gt;
           &lt;input name="rollno" type="text" id="rollno" value="&lt;?php echo $rollno; ?&gt;" size="50" /&gt;
         &lt;/p&gt;
         &lt;p&gt;&lt;span class="style9"&gt;&lt;strong&gt;Class:&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;  *&lt;/strong&gt;
           &lt;input name="class" type="text" id="class" value="&lt;?php echo $class; ?&gt;" size="50" /&gt;
         &lt;/p&gt;
          &lt;p&gt;&lt;span class="style9"&gt;&lt;strong&gt;Fees Date  :&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;  *&lt;/strong&gt;
            &lt;input id="fullDate"  name="date" type="text" value="&lt;?php echo $date; ?&gt;" size="50" /&gt;
         &lt;/p&gt;
          &lt;p&gt;&lt;span class="style9"&gt;&lt;strong&gt;Fees :&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;  *&lt;/strong&gt;
            &lt;input name="fees" type="text" value="&lt;?php echo $fees; ?&gt;" size="50" /&gt;
         &lt;/p&gt;
          &lt;span class="style9"&gt;&lt;strong&gt;Reference&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt; *&lt;/strong&gt;
          &lt;input name="reference" type="text" value="&lt;?php echo $reference; ?&gt;" size="50"&gt;
          &lt;br/&gt;
         &lt;p class="style1"&gt;* required&lt;/p&gt;
       &lt;input type="submit" name="submit" value="Submit"&gt;
       &lt;/div&gt;
       &lt;/form&gt; 
       &lt;?php 
       }
       include('connect-db.php');
  
       if (isset($_POST['submit']))
       { 
       // get form data, making sure it is valid
       $grn = mysql_real_escape_string(htmlspecialchars($_POST['grn']));
       $name = mysql_real_escape_string(htmlspecialchars($_POST['name']));
       $rollno = mysql_real_escape_string(htmlspecialchars($_POST['rollno']));
       $class = mysql_real_escape_string(htmlspecialchars($_POST['class']));
       $fees = mysql_real_escape_string(htmlspecialchars($_POST['fees']));
       $date = mysql_real_escape_string(htmlspecialchars($_POST['date']));
       $reference = mysql_real_escape_string(htmlspecialchars($_POST['reference']));
  
  
       // check to make sure both fields are entered
       if ($grn == '' || $name == '' || $rollno == '')
       {
       // generate error message
       $error = 'ERROR: Please fill in all required fields!';
  
       // if either field is blank, display the form again
       renderForm($grn, $name, $rollno, $class, $fees, $date, $reference, $error);
       }
       else
       {
       // save the data to the database
        mysql_query("INSERT fees SET grn='$grn', name='$name', rollno='$rollno', class='$class', fees='$fees', date='$date', reference='$reference'")
       or die(mysql_error()); 
       echo "&lt;center&gt;KeyWord Submitted!&lt;/center&gt;";
       // once saved, redirect back to the view page
  
       }
       }
       else
       // if the form hasn't been submitted, display the form
       {
       renderForm('','','','','','','','');
       }
  
      ?&gt;
  </code></pre>