I'm trying to create a calculator that just multiplies two numbers together and outputs the result on the same page. Can someone please look at my code and tell me what I'm missing because I haven't been able to find it.
<html>
<head>
<title>Calculator</title>
<link type="css/text", rel="stylesheet", href="calculatorsh.css"/>
</head>
<body>
<div>
<p>This is a calculator that multiplies two numbers together.</p>
<form method="post" action="">
<p><label>First Number:<input type="text" name="number1" /></label></p>
<p><label>Second Number:<input type="text" name="number2"/></label></p>
<input type="submit" value='Calculate'/>
</form>
</div>
<br>
<div>
Result:
<?php
if(isset($_POST['number1'])) && (isset($_POST['number2'])){
$number1=$_POST['number1'];
$number2=$_POST['number2'];
$a=$number1*$number2;
echo $a;
}
?>
</div>
</body
</html>
答案 0 :(得分:2)
Get rid of the extra parentheses in your if statement.
if(isset($_POST['number1']) && isset($_POST['number2'])){
$number1 = $_POST['number1'];
$number2 = $_POST['number2'];
$a = $number1*$number2;
echo $a;
}