You don't need to echo $contents in your function, unless you want it to show up twice. Also, I doubt it's like the '+' and '-' signs in the query string, try something different:
PHP Code:<?php
function open_file($filetype,$increment,$filename)
{
$handle = fopen($filename, 'r');
$contents = fread($handle,filesize($filename));
fclose($handle);
If($increment == 'minus'){
$contents--;
}else{
$contents++;
}
$handle = fopen($filename, $filetype);
fwrite($handle,$contents);
fclose($handle);
return $contents;
}
Switch($_GET['user']){
Case "plus":
echo open_file('w','plus','users.txt');
break;
Case "minus":
echo open_file('w','minus','users.txt');
break;
}
?>




Reply With Quote