Mirage Source
http://www.miragesource.net/forums/

PHP Examples?
http://www.miragesource.net/forums/viewtopic.php?f=142&t=5815
Page 1 of 1

Author:  Lea [ Sun Jun 21, 2009 4:37 pm ]
Post subject:  PHP Examples?

Can anyone more skilled than I please post a few examples of reading a variable (stored in a text file or something? Not sure how this is done?) and writing said variable (from a form) to said storage when a "ok" button is pressed?

sick of weeding and want answers :D

Author:  unknown [ Sun Jun 21, 2009 5:01 pm ]
Post subject:  Re: PHP Examples?

Reads in data from a form textbox & writes it to "testFile.txt" It then reads "testFile.txt" and displays the results
Code:
<html>
<head><title="PHP Test"></title></head>
<body>

<?php if ($_POST["submitData"] != "")
{
   $myFile = "testFile.txt";
   $fh = fopen($myFile, 'w') or die("can't open file");
   fwrite($fh, $_POST["submitData"]);
   fclose($fh);
} ?>

<form action="test.php" method="post">
<input type="text" name="submitData"/>
<input type="submit"/>
</form>

Data read from file:
<?php $myFile = "testFile.txt" or die("Can't open file");
$fh = fopen($myFile, 'r');
$theData = fread($fh,filesize($myFile));
fclose($fh);
echo $theData; ?>

</body>
</html>

Author:  Lea [ Sun Jun 21, 2009 7:22 pm ]
Post subject:  Re: PHP Examples?

thanks much :)

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/