<html>
<body>
<?php
if (!empty($_POST[name]))
echo "Hello " , $_POST["name"];
else echo "Please write your name.";
?>
</body>
</html>[/QUOTE]
Someone did their homework. So, someone deserves help.
"Still couldnt figure out how to keep everything in one file"
You echo the html and escape all of the quotes inside of it. You add a hidden field type with something in it then you have the script check if that field is set. In order for this to be done the script must submit to itself (php global variable $_SERVER['PHP_SELF']).
check if field is set -> [url=http://php.net/manual/en/function.isset.php]PHP: isset - Manual[/url]
escape html code -> [url=http://php.net/manual/en/function.htmlentities.php]PHP: htmlentities - Manual[/url]
code example
[QUOTE]<?php
if(!isset($_POST['form_posted'])) {
$self=$_SERVER['PHP_SELF'];
echo "<form name=/"wickedfire/" method=/"post/" action=/"$self/">
<input type=/"text/" name=/"name/"><br>
<input type=/"hidden/" name=/"form_posted/"><br>";
} else {
$name=$_POST['name'];
echo "How much money you make today, $name?";
echo "Cool, that's enough to buy some beer";
}
?>[/QUOTE]