I am making a 'health program' and you get 1 point per 'healthy' thing you do each day, for example, if you have 30 minutes of exercise you get a point. How it works is shown below:
<form method="post">
<label>Did you have 30 minutes of exercise today? (+1)</label>
<select name="question">
<option value="yes">Yes</option>
<option value="no">No</option>
</select> <input type="submit" class="btn btn-outline-light" name="form1">
</form>
<form method="post">
<label>Have you drinken 8 glasses of water today? (+1)</label>
<select name="question">
<option value="yes">Yes</option>
<option value="no">No</option>
</select> <input type="submit" class="btn btn-outline-light" name="form2">
</form>
<form method="post">
<label>Did you use your phone for more than two hours today? (-1)</label>
<select name="question">
<option value="yes">Yes</option>
<option value="no">No</option>
</select> <input type="submit" class="btn btn-outline-light" name="form3">
</form>
<?php
/* Then using PHP I want to have each form submitted, add or remove 1 from an overall score, something like this: */
$score = 0;
if (isset($_POST['form1'])) {
$question = $_POST['question'];
if ($question = "yes") {
// +1 point
$score = +1;
}
}
if (isset($_POST['form2'])) {
$question = $_POST['question'];
if ($question = "yes") {
// +1 point
$score = +1;
}
}
if (isset($_POST['form3'])) {
if ($question = "yes") {
// -1 point
$score = +1;
}
} ?>
Then I want either +1 or -1 from $score. I'm not sure how to do the actual adding of the points using PHP. I want the $score to be updated outside of the if statement otherwise, for each if statement it will add one and $score will still be = to 1
Thanks!
Jacob
</div>