lundi 27 juillet 2015

PHP site not working right

I am trying to make a online "bank" for me and my friends to use in games, like Minecraft. I got most of the things working, but the trade thing. The setup is that I use a text file as the storage for the amount of money we have, then call those text files from within my PHP code, but the math isn't working right.I will put a link to a zipped version of the whole site.

Zipped file: [GOOGLE DOCS HOSTED ZIP]

<!DOCTYPE html>
<html>
<body>
<?php
$riley = fopen("riley.txt", "r") or die("Unable to read data!");
$ethan = fopen("ethan.txt", "r") or die("Unable to read data!");
$ethanw = fopen("ethan.txt", "w") or die("Unable to write data!");
$rileyw = fopen("riley.txt", "w") or die("Unable to write data!");
$user = $_SESSION["user"];
$amm = $_POST["amm"];
if ($user == "ethan") {
        $txt = $ethan - $amm;
        fwrite($ethanw, $txt);
        $txt = $riley + $amm;
        fwrite($rileyw, $txt);
} 
if ($user == "riley") {
        $txt = $riley - $amm;
        fwrite($rileyw, $txt);
        $txt = $ethan + $amm;
        fwrite($ethanw, $txt);
} 
fclose($riley);
fclose($ethan);
?>
<p> transaction made. Redirecting to home in 3 seconds </p>
<?php
sleep(3);
header("Location: bank.php");
die();
?>
</body>
</html>



Aucun commentaire:

Enregistrer un commentaire