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>
<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>