0
I am new with PHP and I am making a calculator using buttons and I am having error, I would like to know the reason for the error, so far only did the sum and subtraction part.
<!doctype html>
<html lang="pt-br">
<head>
<title>Resultado</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<body>
<?php
$n1 = $_GET['numero1'];
$n2 = $_GET['numero2'];
$op = $_GET['escolha'];
switch ($escolha){
case = 'Soma':
$result = $n1 + $n2;
echo "O Resultado é: $result";
break;
case ='Subtração':
$result = $n1 + $n2;
echo "O Resultado é: $result";
break;
}
?>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin="anonymous"></script>
</body>
</html>
Form
<!doctype html>
<html lang="pt-br">
<head>
<title>Calculado Boladonaaa</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div clas="row">
<div clas="col-md-6">
<form id="formulario" name="formulario" method="get"
action="resultado.php">
<h3>Calculada</h3>
<div class="form-group">
<label for="numero1">Digite um número para calculo</label>
<input type="number" class="form-control" name="numero1" id="numero1"
placeholder="Digite o primeiro número">
</div>
<div class="form-group">
<label for="numero2">Digite o segundo número para o calculo</label>
<input type="number" class="form-control" name="numero2" id="numero2"
placeholder="Digite o segundo número"><br>
</div>
<h4>Selecione a operação desejada<h4>
<input class="btn btn-danger" type="submit" name="operacao" value="Soma" id="Soma">
<input class="btn btn-primary" type="submit" name="operacao" value="Subtração" id="Subtração">
<input class="btn btn-success" type="submit" name="operacao" value="Multiplicação" id="Multiplicação">
<input class="btn btn-warning" type="submit" name="operacao" value="Divisão" id="Divisão">
</form>
</div>
</div>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin="anonymous"></script>
</body>
</html>
The result page.php is returning not found - 404 Error.
– ElvisP
And, by the way, what’s the mistake?
– Woss
( ! ) Parse error: syntax error, Unexpected '=' in C: wamp64 www project_calculated result.php on line 24, in the sum case line.
– Lucas Almeida
This equal does not exist, see documentation.
– Woss