PHP Code:
<?php
if ($_POST['send']) {
// variable telling the server what to echo
$message = "<div id='main'><p><b>Muhaha, i know all about you!</b></p>
<p> </p>
<p>Your name is <span class='input'>". $_POST['fname'] ." ". $_POST['lname'] ."!</span></p>
<p> </p>
<p>You're <span class='input'>". $_POST['age'] ."</span> years old and your favorite movie is <span class='input'>". $_POST['favmov'] .".</span>
<p> </p></div>";
// echoing the above message
echo $message;
// replaces certain charaters with other characters
$messagetodo = str_replace("<p> </p>", "
", $message);
$messagetodo = str_replace(" ", " ", $message);
$messagetodo = strip_tags($messagetodo);
// checks if there exists a dir named 'test'
// if not it creates it
if (!is_dir("test")) {
mkdir("test");
}
// variable telling the server what to call the created file
// here making a random number name
$name = "test/test". rand(1, 100) .".txt";
// opens the created file
$open = fopen($name, "w+");
if ($open) {
if (fwrite($open, $messagetodo)) {
// message that the server created file
$msg = "Successfully Created file: ". $name;
} else {
// error message that the server could not write the specified file
$msg = "Error in fwrite('". $open ."', '$message');";
}
} else {
// error message that the server could not open the specified file
$msg = "Error in fopen('". $name ."', 'w+');";
}
}
?>
<html>
<head>
<title>My first php-script width the GET and POST included!</title>
<style type="text/css">
p {
font-family: Verdana;
font-size: 18px;
color: #FFFFFF;
}
span.input {
font-family: Verdana;
font-size: 18px;
color: #FF0000;
}
#main {
margin: auto;
text-align: center;
}
</style>
<script type="text/javascript">
<!--
var c = 0;
function check()
{
frm = document.form1;
if (frm.fname.value == '') {
alert('Please fill in your name!');
c = 1;
}
if (frm.lname.value == '') {
alert('Please fill in your last name!');
c = 1;
}
if (frm.favmov.value == '') {
alert('Please fill in your favourite movie!');
c = 1;
}
if (frm.age.value == '') {
alert('Please fill in your age!');
c = 1;
}
if (c != 1) {
frm.submit();
}
}
-->
</script>
</head>
<body bgcolor="#000000" text="#FFFFFF">
<div id="main">
<h1>Fill out the form!</h1>
<p><?=$msg;?></p>
<form action="<?=$_SERVER['PHP_SELF'];?>" method="post" name="form1">
<p>First name: <input type="text" name="fname"></p>
<p>Last name: <input type="text" name="lname"></p>
<p>Your favourite movie: <input type="text" name="favmov"></p>
<p>Your age: <input type="text" name="age"></p>
<p><input type="reset" value="Start over"> <input type="button" value="OK" name="send" onClick="check();" /></p>
</form>
</div>
</body>
</html>
Then Illusion ;)