Associate
- Joined
- 18 Oct 2002
- Posts
- 710
- Location
- Somerset
Should this work?
I have a page up that has several input boxes all controlled by 1 submit button,
when everything is submitted each entry from each box is put through $POST and assigned to separate variables.
then a function runs that takes these variable values and writes them to a txt file.
But its not working.
Here is a cut down version of the code to include 1 entry instead of the 5 or 6 i am trying to use.
Form on page.
Takes submitted info from form and assigns to variables then runs storeinfo function.
writes these variables to txt file
I was thinking that the 2nd section was not being called but i think it is because the txt file contains data if i write some thing different between the "" in the 3rd section and as far as i understand it the storeinfo function will only run if it is called? which the 2nd section does
I have a page up that has several input boxes all controlled by 1 submit button,
when everything is submitted each entry from each box is put through $POST and assigned to separate variables.
then a function runs that takes these variable values and writes them to a txt file.
But its not working.
Here is a cut down version of the code to include 1 entry instead of the 5 or 6 i am trying to use.
Form on page.
Code:
<title>Enter info</title>
<form method="post" action="<?php echo $PHP_SELF;?>">
<div align="center">Player Name :
<input type="text" size="12" maxlength="25" name="playername">
<input type="submit" value="Submit Info" name="enter">
</form>
Takes submitted info from form and assigns to variables then runs storeinfo function.
Code:
<?php
$playername = $_POST["playername"];
if (!isset($_POST['enter']))
{
storeinfo();
}
?>
writes these variables to txt file
Code:
<?php
function storeinfo(){
//open store file in append mode
$myFile = "store.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
//add new moon details to the end
$stringData = ".$playername";
fwrite($fh, $stringdata);
fclose($fh);
}
?>
I was thinking that the 2nd section was not being called but i think it is because the txt file contains data if i write some thing different between the "" in the 3rd section and as far as i understand it the storeinfo function will only run if it is called? which the 2nd section does