Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding using HTML forms and PHP
    primarykey
    data
    text
    <p>I'm having some trouble adding numbers taken from a HTML form. I know this is a really basic question, but nothing seems to work. I'm trying to add up an user's score in a psychical game, such as Scrabble. The code is supposed to get the inputted scores and the old scores and add them up, although I haven't added the part to add the numbers yet. Where and how can I display the added score number in the code? You can access the web application at: ripdvd.x10.mx/index.php. Thanks to Michi for already trying to help me with this!</p> <pre><code>&lt;?php // Get data from HTML form. $addScore1 = $_POST['addScore1']; $addScore2 = $_POST['addScore2']; $oldScore1 = $_POST['oldScore1']; $oldScore2 = $_POST['oldScore2']; ?&gt; // Generate HTML form &lt;html&gt; &lt;head&gt; &lt;title&gt;Score Add&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="displayNames"&gt; &lt;p&gt;&lt;?php echo $player1; ?&gt; current score: &lt;?php echo $oldScore1; ?&gt; &lt;form method="post" action=""&gt; &lt;label for="addScore1"&gt;Enter your score:&lt;/label&gt; &lt;input type="text" name="addScore1" id="addScore1" /&gt; &lt;input type="hidden" name="oldScore1" id="oldScore1" value="&lt;?php echo $oldscore1; ?&gt;" /&gt; &lt;input type="submit" /&gt; &lt;/p&gt; &lt;p&gt;&lt;?php echo $player2; ?&gt; current score: &lt;?php echo $oldScore2; ?&gt; &lt;label for="addScore2"&gt;Enter your score:&lt;/label&gt; &lt;input type="text" name="addScore2" id="addScore2" /&gt; &lt;input type="hidden" name="oldScore2" id="oldScore2" value="&lt;?php echo $oldscore2; ?&gt;" /&gt; &lt;input type=\"submit\"/&gt; &lt;/form&gt; &lt;/p&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    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. 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