Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I made several changes to your code (including the removal of cookies - hope that's ok). If you can live without cookies, try this:</p> <pre><code>&lt;?php // Get data from HTML form. // Gets the player names $player1 = $_POST['player1']; $player2 = $_POST['player2']; if ($_POST['addScore1'] == null) $addScore1 = 0; else $addScore1 = $_POST['addScore1']; if ($_POST['addScore2'] == null) $addScore2 = 0; else $addScore2 = $_POST['addScore2']; if ($_POST['oldScore1'] == null) $oldScore1 = 0; else $oldScore1 = $_POST['oldScore1']; if ($_POST['oldScore2'] == null) $oldScore1 = 0; else $oldScore2 = $_POST['oldScore2']; $curr1=$oldScore1+$addScore1; $curr2=$oldScore2+$addScore2; if ($_POST['clse'] == "t"){ $curr1 = 0; $curr2 = 0; } // Generate HTML form ?&gt; &lt;!DOCTYPE HTML&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Score Add&lt;/title&gt; &lt;link rel=StyleSheet href="style.css" type="text/css"&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; &lt;/head&gt; &lt;body&gt; &lt;form method="post" action="&lt;?php echo $_SERVER['PHP_SELF'];?&gt;"&gt; &lt;p class="par"&gt; &lt;label for="addScore1"&gt;Enter your score, &lt;?php echo $player1; ?&gt;:&lt;/label&gt; &lt;input type="text" name="addScore1" id="addScore1" class="textbox" /&gt; &lt;input type="hidden" name="oldScore1" id="oldScore1" value="&lt;?php echo $curr1; ?&gt;" /&gt; &lt;input type="submit" class="button" value="Add Score!" /&gt; &lt;/p&gt; &lt;p class="par"&gt; &lt;label for="addScore2"&gt;Enter your score, &lt;?php echo $player2; ?&gt;:&lt;/label&gt; &lt;input type="text" name="addScore2" id="addScore2" class="textbox"/&gt; &lt;input type="hidden" name="oldScore2" id="oldScore2" value="&lt;?php echo $curr2; ?&gt;" /&gt; &lt;input type="submit" class="button" value="Add Score!"/&gt; &lt;/p&gt; &lt;input type="hidden" name="player1" value="&lt;?PHP echo $player1;?&gt;" /&gt; &lt;input type="hidden" name="player2" value="&lt;?PHP echo $player2;?&gt;" /&gt; &lt;/form&gt; &lt;form method="post" action="&lt;?php echo $_SERVER['PHP_SELF'];?&gt;"&gt; &lt;input type="hidden" name="clsc" id="clsc" value="t" /&gt; &lt;input type="submit" class="reset" value="Clear Scores" /&gt; &lt;/form&gt; &lt;!--Shows player and score--&gt; &lt;p class="par"&gt;&lt;?php echo $player1;?&gt;:&lt;?php echo $curr1?&gt;&lt;/p&gt; &lt;p class="par"&gt;&lt;?php echo $player2;?&gt;:&lt;?php echo $curr2?&gt;&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Note, I haven't actually ran this, but try it and let me know if you get any errors or still have problems.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload