php老虎机学分

时间:2013-02-06 12:24:46

标签: php forms get credits

嘿,我正在制作一台老虎机,差不多完成了。我唯一需要的是信用保留,所以它只是在信用额度上加点。就像我有100个学分,然后获得25个学分,我希望它说125学分。现在我不知道如何获得该轮次的积分。
这就是我得到的:

            <?
    $tal = rand (1,3 ); {
    echo "<img src='css/billeder/enarmet$tal.gif' class=billed />"; 
    $tal2 = rand (1,3 ); 
    echo "<img src='css/billeder/enarmet$tal2.gif' class=billed />"; 
    $tal3 = rand (1,3 ); 
    echo "<img src='css/billeder/enarmet$tal3.gif' class=billed />"; }
    ?>
            </div>
            <div id="credits">
                <h3 id="credits2">CREDITS</h3>
                <h3 id="credits3"><?php 
                $credits=$_GET['credits'];
        if ($tal . $tal2 . $tal3 == 111){
            ($credits=($credits+100));              
        }
        if ($tal . $tal2 . $tal3 == 222){
            ($credits=($credits+50));                
        }
        if ($tal . $tal2 . $tal3 == 333){
            ($credits=($credits+25));               
        }
        echo $credits;
        ?></h3>
            </div>
        </div>
        <form action="index.php" method="POST">
            <input type="submit" value="SPIN" class="knap">
        </form> 
        <form action="cashout.php" method="POST">
            <input type="submit" value="CASH OUT" class="knap">
        </form>
    </div>

2 个答案:

答案 0 :(得分:0)

使用会话怎么样?使用

存储和检索会话存储中的信用
session_start();
$credits = $_SESSION['credits'];

位于脚本顶部,

$_SESSION['credits'] = $credits;

在底部。

这种方式将在页面加载之间保留信用。

答案 1 :(得分:-1)

您可以删除以下行末尾的花括号,不需要并尝试使用。

<?
    $tal = rand (1,3 ); { // remove the open brace
    echo "<img src='css/billeder/enarmet$tal.gif' class=billed />"; 

...

echo "<img src='css/billeder/enarmet$tal3.gif' class=billed />"; } // remove the close brace
    ?>