Perform count-up and count-down by clicking in php
I'm writing a process to calculate the total
I would like to have a professor because I get an error.
Also, I would like to display $Total on a separate page
Does not work with require.
<? php
$cut = 0;
if ($_ POST ['cut']) {
$cut = $_POST ['cut'];
}
if ($_POST ['cutplus']) {
$cut ++;
} elseif ($_POST ['cutminus']) {
$cut--;
}
$color = 0;
if ($_ POST ['color']) {
$color = $_POST ['color'];
}
if ($_POST ['colorplus']) {
$color ++;
} elseif ($_POST ['colorminus']) {
$color--;
}
$total = 0;
$total = $cut + $color;
?>
<? = $total?>
<? = $cut?>
<? = $color?>
<form action = "" method = "POST">
<input type = "hidden" name = "cut" value = "<? = $cut?>">
<input type = "submit" name = "cutplus" value = "reception">
</form>
<form action = "" method = "POST">
<input type = "hidden" name = "cut" value = "<? = $cut?>">
<input type = "submit" name = "cutminus" value = "Information">
</form>
<br>
<form action = "" method = "POST">
<input type = "hidden" name = "color" value = "<? = $color?>">
<input type = "submit" name = "colorplus" value = "reception">
</form>
<form action = "" method = "POST">
<input type = "hidden" name = "color" value = "<? = $color?>">
<input type = "submit" name = "colorminus" value = "Information">
</form>
Error
Notice: Undefined index: cut in C: \ xampp \ htdocs \ gomi \ newfile.php on line 4
Notice: Undefined index: cutplus in C: \ xampp \ htdocs \ gomi \ newfile.php on line 8
Notice: Undefined index: cutminus in C: \ xampp \ htdocs \ gomi \ newfile.php on line 10
Notice: Undefined index: color in C: \ xampp \ htdocs \ gomi \ newfile.php on line 17
Notice: Undefined index: colorplus in C: \ xampp \ htdocs \ gomi \ newfile.php on line 21
Notice: Undefined index: colorminus in C: \ xampp \ htdocs \ gomi \ newfile.php on line 23
-
Answer # 1
Related articles
- php - [wordpress] i got an error and can't log in
- php tags wrapped in and tags do not close
- php - when i page and view pdo, the data i get from pdo is empty
- php - i want to count multiple columns of the same format in sql at once
- php - laravel count becomes 0 and returns
- php - when i execute count from sql in wordpress, i can get it but i can not expand it from the array
- javascript and php variables
- php - calling and displaying data from sql does not work
- php - join and display tables in sql
- i can't connect php and mysql
- box click and text display in php
- php - how to use for and while
$_ POST ['cut']
, and when referring to a variable that does not know whether it exists or notNormally uses isset ().
For example:
The equivalent behavior can be written on a single line using filter_input ().
From that point of view, check with isset () and refer to it.
And be careful to verify that the received parameters are not unexpected.