将PHP变量数据返回到HTML页面

I am fairly new to php and have only written basic post email returns. However what im trying to achive now is to return the data held within a variable back to the webpage in a specific location on the page.

So far I have a form that collects the data Name & Surname, this is collected by php.

$firstnameField = $_POST ['name'];
$surnameField = $_POST ['surname'];

All I want to do is print the data within these variables back to the screen in a specific location on the page. I have looked around but others are talking about databases and ajax, and I havent the slightest about that stuff.

Thanks in advance.

It's pretty simple: just use echo/print inside a <?php ?> code block wherever you want that variable printed in your document:

<?php

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $firstname = $_POST['name'];
}

?>

<html>

<body>

<?php if (isset($firstname)) { echo "<p>Hello, $firstname</p>"; } ?>

<form method="POST">
Enter a name: <input type="text" name="name" />
</form>

</body>

</html>
<?php
if ((isset($_POST["dataEntered"])) && ($_POST["dataEntered"] == "Yes"))
echo "Hello! " . $_POST["name"] . " " . $_POST["surname"];
else
{
?>
    <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post" name="form1" id="form1">
        <table>
          <tr>
            <td>Name:</td>
            <td><input name="name" type="text" id="name" value="" size="32" /></td>
          </tr>
          <tr>
            <td>Surname:</td>
            <td><input name="surname" type="text" id="surname" value="" size="32" /></td>
          </tr>
          <tr>
            <td colspan="2"><input type="submit" value="Send Form" /></td>
          </tr>
        </table>
        <input type="hidden" name="dataEntered" value="Yes" />
      </form>
 <?php
}
?>