Make a textbox generate text files like t1.txt t2.txt t3.txt, and so on
I have this code on my website:
<form name="form" method="post">
<input type="text" name="text_box" size="50"/>
<input type="submit" id="search-submit" value="submit" />
</form>
<?php
if(isset($_POST['text_box'])) { //only do file operations when
appropriate
$a = $_POST['text_box'];
$myFile = "t.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $a);
fclose($fh);
}
?>
The thing i'd like it to do is that when there is already a t.txt, it'll
create a t2.txt, and then t3.txt and so on, so it doesen't overwrite the
text in the previous t.txt.
No comments:
Post a Comment