So, I am making a salary calculator Using Switch Statement to give value to $NetS variable, but when I try to echo in the textbox, it gives this error:
Undefined variable: NetS in C:\wamp\www\salary.php on line 73 Call Stack #TimeMemoryFunctionLocation 10.0003390392{main}( )...\salary.php:0 " />
Here is my code
<body>
<?php
if(isset($_POST['Submit']))
{
    $Dept = $_POST['Dept'];
    $ES = $_POST['ES'];
    $NetS;
    switch($Dept)
    {
        case "da":
        $NetS = $ES - ($ES*1/100)-500;
        break; 
        case "db":
        $NetS = $ES - ($ES*2/100)-500;
        break;
        case "dc":
        $NetS = $ES - ($ES*3/100)-500;
        break;
        case "dd":
        $NetS = $ES - ($ES*5/100)-500;
        break;
        default: echo"Invalid Choice or error";
        
        break;
    
    }
}
?> 
<h1 style="text-align:center;">CS310 Open Source Web Application Development</h1>   
<h3 style="text-align:center;" >Assignment no 1</h3>
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']);?>" method="POST">
<br><br>
Select Department
<select name="Dept" id="Dept" class="form-control" style="width:230px">
<option value="">Select Options</option>
<option value="da">Department A</option>
<option value="db">Department B</option>
<option value="dc">Department C</option>
<option value="dd">Department D</option>
</select>
</form>
<br><br>
Employee Salary
<input type="text" name="ES" Placeholder="Enter Employee Salary" class="form-control" style="width:230px"/>
<br>
<input type="submit" name="Submit" class="tn btn-success" style="width:120px"/>
<br> <br>
Net salary
<input type="text" class="form-control" style="width:230px" name="NetSalary" value="<?php echo $NetS; ?>" />
</body>
</html>
 
     
    
