File Creator

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
RMX
Forum Newbie
Posts: 3
Joined: Wed Jan 29, 2003 2:09 pm

File Creator

Post by RMX »

Hi all. I have coded the script(see bellow) and i want to that script creates one file with such content as i want, but it creates 2 files: one with my content, second emty. Can you help me, cuz i'm new in PHP
P.S sorry for my bad english
code:
<form method="POST"action="http://<?=$SERVER_NAME?><?=$PHP_SELF?>">
<input type="text" name="pirmas" size="20"><input type="text" name="antras" size="20"></p>
<p><input type="submit" value="OK" name="OK"></p>
</form>

</body>

</html>
<?
$username = "RMX";
$password = "123";
$edit = "<form method=POST>Žinutė</p><p><textarea rows=7 name=zinute cols=25></textarea></p><p><input type=submit value=Postinti name=btn></p></form>";
if ($OK == "OK") {
if ($pirmas == $username && $antras == $password) {echo($edit);}
else {echo('Neteisingai');}
}
$turinys = $zinute;
while (file_exists("naujiena$i.txt")) {
$i = $i+1;
}
$filename = "naujiena$i.txt";
$fp = fopen($filename,"w");
fwrite($fp);
fclose($fp);
if ($post == "Papostinti") {
$handle = fopen($filename, "a");
fwrite($handle, $turinys);
fclose($handle);
}
?>
Post Reply