Adding $_PostVariable existing $Variable
I am using DW CS3 to create php code to get the $playerScoreTotal by adding the new game score variable $_POST['playerScore'] to $oldScore the last total game score.
$playerScoreTotal = $oldScore + $_POST['playerScore'];
The php page is used to hold a swf game file. A button in the swf activates a post action to send the swf score to the php page. The game can be replayed so a combined total score needs to be created. Once I have this working I will need to then send the $playerScoreTotal value by a post from the php page to the database to update the players score total. Will the post from the swf conflict with the post from the php page?
Code below does not add the posted score to the old score. I believe that it is overwriting with the posed score value. I have worked with variables before but cannot remember how of find an appropriate example/tutorial. Do I need to create a separate math function? Use global variables? Please provide clear code example and logic. Thank you.
<?php
if (!isset($_SESSION)) {
session_start();
}
?>
<?php
$playerScore = '';
$oldScore = $playerScore;
$playerScoreTotal = $oldScore + $_POST['playerScore'];
if (isset($_POST['playerScore']))
{
$playerScore = $_POST['playerScore'];
}
?>
Puzzle Total Score:<?php echo $playerScoreTotal; ?>Post Score:<?php echo $playerScore; ?>