Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Hi im new :p
Iv got a little thing i want to do. I want to input a few numbers and submit them, then i want them to be written out on a webpage after which i want to store them in a serverside text file. Sofar i have this code:Code: Select all
<html>
<head></head>
<body>
<pre>
<?php
$arr = file("/var/www/test.txt");
foreach ($arr as $line) {
print $line;
}
?>
</pre>
<?php
// retrieve form data
$input1 = $_POST['msg1'];
$input2 = $_POST['msg2'];
$input3 = $_POST['msg3'];
$input4 = $_POST['msg4'];
$iive = $input1-$input2;
$filename = '/var/www/test.txt';
$somecontent = '';
$kuupaev = date("l dS \of F Y h:i:s A");
// use it
$somecontent = "$kuupaev";
$somecontent += "'Sisse tuli: ' + $input1 + '<br>' ";
$somecontent += "'Välja läks: ' + $input2 + '<br>' ";
$somecontent += "'Iiive: ' + $iive + '<br>' ";
$somecontent += "'Katkiseid Arvuteid: ' + $input3 + '<br>' ";
$somecontent += "'Korras Arvuteid: ' + $input4 + '<br>' ";
echo $somecontent;
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success.";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
?>
<br>
</body>
</html>This might be horribly wrong but as i said im new!
Any help accepted with open hands
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]