My php is printing out the numbers instead of the result. Example, it'll print out "3+3" instead of "6".
What am i doing wrong? Can someone explains how php reads the code and how i can fix it. - new beginner learning php
<?php
//Check to see if the submit button got posted
if(isset($_POST['submit'])){
//If it did, get the values from the textbox
$first_number = $_POST['first_number'];
$second_number= $_POST['second_number'];
$operator = $_POST['operator'];
//Check to see if they are empty
if(!empty($first_number) && !empty($second_number)){
echo $first_number . $operator . $second_number;
}
else {
echo 'Please fill out all the forms';
}
}
?>
</head>
<body>
<div id='wrap'>
<header id='header'>
<h1> This Is A Simple Math Calculator </h1>
</header>
<section id='main'>
<form action='math.php' method='POST'>
<table cellspacing='10px'>
<tr>
<td>
<input type='text' name='first_number' placeholder='First Number' size='15px'/>
</td>
<td>
<select name='operator'>
<option value='+'>+</option>
<option value='-'>-</option>
<option value='*'>*</option>
<option value='/'>/</option>
<option value='%'>%</option>
</select>
</td>
<td>
<input type='text' name='second_number' placeholder='Second Number' size='15px' />
</td>
<td>
<input type='submit' name='submit' value='=' />
</td>
<td>
<input type='text' name='answer' placeholder='' size='10px' />
</td>
</tr>
</table>
</form>
</section>
<footer>
<p> MADE BY @KD </p>
</footer>