Click to See Complete Forum and Search --> : Writing to a file on my home computer??


nvidia
03-03-2007, 11:03 AM
Hi i am trying to write values to a file called C2.txt based on the user selecting radio button values. It is saved under my directory C: but everytime the user has selected the radio values and press the submit button, the values are not written to my text file. Can someone tell me why it is not writting?



<html>
<head>
<title> Page 2 </title>
</head>
<body>
<?php
session_start();
$selection = $_POST['select'];
$filename = "C:\C2.txt";


function file_put_contents($filename,$selection)
{
$fp = fopen($filename,'a+');
if(!$fp)
{
return false;
}
else
{
$write = fwrite($fp, "$selection\r\n");
fclose($fp);
return true;
}
}
$put = file_put_contents($filename, $selection);
$contents = file_get_contents("C2.txt");

$Hugh_Jackman = "Hugh Jackman";
$Tom_Cruise = "Tom Cruise";
$Halle_Berry = "Halle Berry";

$countHugh = substr_count($contents,"$Hugh_Jackman ");
$countTom = substr_count($contents,"$Tom_Cruise");
$countHalle = substr_count($contents,"$Halle_Berry");

?>

<br />
<? echo $countHugh ?> % chose Hugh Jackman to do a bush tucker trial
<br />
<? echo $countTom ?> % chose Tom Cruise to do a bush tucker trial
</br>
<? echo $countHalle ?> % chose Halle Berry to do a bush tucker trial

</body>
</html>

carlh
03-03-2007, 04:08 PM
it's going to look at c:\ on the server, not the client. i think the only way to write to a file on a client system is to have them download the file through a link or something like that

aussie girl
03-03-2007, 07:24 PM
what server are you using? people cannot connect straight to your computer using that script, and as carlh says the pathway will not be a C: should be something like ./directoryname/C2.txt