3v4l.org

run code in 300+ PHP versions simultaneously
<?php if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["CLASS"])) { $CLASS_Err = "* Customer Class is required"; } else { $CLASS = test_input($_POST["CLASS"]); } if (empty($_POST["UNITS"])) { $UNITS_Err = "* Units is required"; } else { $UNITS = test_input($_POST["UNITS"]); } if (empty($_POST["PUMPZONE"])) { $PUMPZONE_Err = "* Pump Zone is required"; } else { $PUMPZONE = test_input($_POST["PUMPZONE"]); } if (empty($_POST["METERSIZE"])) { $METERSIZE_Err = "* Meter Size is required"; } else { $METERSIZE = test_input($_POST["METERSIZE"]); } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <form name="GETRATES" action="http://wvwdrates.com/bill-estimator" method="post"> <table> <tr><td> <table> <tr><td width="50%">Customer Class:</td><td width="50%"> <SELECT NAME="CLASS"> <OPTION VALUE="">Select One...</OPTION> <OPTION VALUE="R" <?php if ($_POST['CLASS'] == "R") echo 'selected="selected" '; ?>>Residential</OPTION> <OPTION VALUE="M" <?php if ($_POST['CLASS'] == "M") echo 'selected="selected" '; ?>>Multi-Family</OPTION> <OPTION VALUE="C" <?php if ($_POST['CLASS'] == "C") echo 'selected="selected" '; ?>>Non-Residential</OPTION> <OPTION VALUE="RC" <?php if ($_POST['CLASS'] == "RC") echo 'selected="selected" '; ?>>Recycled</OPTION> </SELECT><span class="error"> <?php echo $CLASS_Err;?></span> </td></tr> <tr><td>Units:</td><td><input value="<?php echo $UNITS;?>" name="UNITS" type="text" size="10" maxlength="10" /><span class="error"> <?php echo $UNITS_Err;?></span></td></tr> <tr><td width="50%">Pump Zone:</td><td width="50%"> <SELECT NAME="PUMPZONE"> <OPTION VALUE="">Select One...</OPTION> <OPTION VALUE="1" <?php if ($_POST['PUMPZONE'] == "1") echo 'selected="selected" '; ?>>1</OPTION> <OPTION VALUE="2" <?php if ($_POST['PUMPZONE'] == "2") echo 'selected="selected" '; ?>>2</OPTION> <OPTION VALUE="3" <?php if ($_POST['PUMPZONE'] == "3") echo 'selected="selected" '; ?>>3</OPTION> </SELECT><span class="error"> <?php echo $PUMPZONE_Err;?></span> </td></tr> <tr><td width="50%">Meter Size:</td><td width="50%"> <SELECT NAME="METERSIZE"> <OPTION VALUE="">Select One...</OPTION> <OPTION VALUE="5/8" <?php if ($_POST['METERSIZE'] == "5/8") echo 'selected="selected" '; ?>>5/8</OPTION> <OPTION VALUE="3/4" <?php if ($_POST['METERSIZE'] == "3/4") echo 'selected="selected" '; ?>>3/4</OPTION> <OPTION VALUE="1" <?php if ($_POST['METERSIZE'] == "1") echo 'selected="selected" '; ?>>1</OPTION> <OPTION VALUE="1 1/2" <?php if ($_POST['METERSIZE'] == "1 1/2") echo 'selected="selected" '; ?>>1 1/2</OPTION> <OPTION VALUE="2" <?php if ($_POST['METERSIZE'] == "2") echo 'selected="selected" '; ?>>2</OPTION> <OPTION VALUE="3" <?php if ($_POST['METERSIZE'] == "3") echo 'selected="selected" '; ?>>3</OPTION> <OPTION VALUE="4" <?php if ($_POST['METERSIZE'] == "4") echo 'selected="selected" '; ?>>4</OPTION> <OPTION VALUE="6" <?php if ($_POST['METERSIZE'] == "6") echo 'selected="selected" '; ?>>6</OPTION> <OPTION VALUE="8" <?php if ($_POST['METERSIZE'] == "8") echo 'selected="selected" '; ?>>8</OPTION> </SELECT><span class="error"> <?php echo $METERSIZE_Err;?></span> </td></tr> <tr><td align="left"> <input type="image" style="border:0px;" value="" src="http://wvwdrates.com/calculate.png"> </form></td> <td align="right"> <form name="RESET" action="http://wvwdrates.com/bill-estimator" method="post"> <input type="hidden" name="CLASS" value=""> <input type="hidden" name="UNITS" value=""> <input type="hidden" name="PUMPZONE" value=""> <input type="hidden" name="METERSIZE" value=""> <input type="submit" value="CLEAR"> </form></td> </tr></table> </td> </tr> </table> <BR><BR><BR> <? ///////// FORM INPUT ///////////////// $CLASS = $_POST['CLASS']; $UNITS = $_POST['UNITS']; $PUMPZONE = $_POST['PUMPZONE']; $METERSIZE = $_POST['METERSIZE']; ///////// STATIC DATA ///////////////// $commodity_new_tier1 = 2.69; $commodity_new_tier2 = 3.08; $commodity_new_tier3 = 3.08; $commodity_new_multi = 2.89; $commodity_new_comm = 2.95; $commodity_new_rec = 1.56; $commodity_current_tier1 = 2.46; $commodity_current_tier2 = 3.08; $commodity_current_tier3 = 3.08; $commodity_current_multi = 2.77; $commodity_current_comm = 2.81; $commodity_current_rec = 1.49; $pumpzone_new_zone1 = 0; $pumpzone_new_zone2 = 0.19; $pumpzone_new_zone3 = 0.36; $pumpzone_current_zone1 = 0; $pumpzone_current_zone2 = 0.19; $pumpzone_current_zone3 = 0.35; $meter_new_58 = 18.29; $meter_new_34 = 18.29; $meter_new_1 = 23.04; $meter_new_112 = 54.43; $meter_new_2 = 71.07; $meter_new_3 = 145.53; $meter_new_4 = 229.30; $meter_new_6 = 435.87; $meter_new_8 = 671.11; $meter_new_10 = 0; $meter_current_58 = 17.08; $meter_current_34 = 17.08; $meter_current_1 = 21.60; $meter_current_112 = 46.18; $meter_current_2 = 70.73; $meter_current_3 = 128.92; $meter_current_4 = 211.86; $meter_current_6 = 414.54; $meter_current_8 = 658.34; $meter_current_10 = 0; ///////// FORMULAS ///////////////// if ( $UNITS<=12 && $UNITS>=0) { $tier1=$UNITS; $tier2='N/A'; $tier3='N/A'; } else { $tier1='N/A'; } if ( $UNITS<=39 && $UNITS>=0) { $tier1=$UNITS; $tier2=27; $tier3='N/A'; } else { $tier1='N/A'; } if( $UNITS >=12 && $UNITS <=40) { $tier1=12; $tier2 = $UNITS-12; $tier3='N/A'; } else { $tier2='N/A'; } if ( $UNITS>=39 ) { $tier1=12; $tier2=27; $tier3=$UNITS-39; } else { $tier3='N/A'; } if ($_POST['METERSIZE']=='5/8') { $baserate_new = 18.29; $baserate_current = 17.08; } if ($_POST['METERSIZE']=='3/4') { $baserate_new = 18.29; $baserate_current = 17.08; } if ($_POST['METERSIZE']=='1') { $baserate_new = 23.04; $baserate_current = 21.60; } if ($_POST['METERSIZE']=='1 1/2') { $baserate_new = 54.43; $baserate_current = 46.18; } if ($_POST['METERSIZE']=='2') { $baserate_new = 71.07; $baserate_current = 70.73; } if ($_POST['METERSIZE']=='3') { $baserate_new = 145.53; $baserate_current = 128.92; } if ($_POST['METERSIZE']=='4') { $baserate_new = 229.30; $baserate_current = 211.86; } if ($_POST['METERSIZE']=='6') { $baserate_new = 435.87; $baserate_current = 414.54; } if ($_POST['METERSIZE']=='8') { $baserate_new = 671.11; $baserate_current = 658.34; } if ($CLASS == "R") { $newrate_tier1 = $tier1 * $commodity_new_tier1; $newrate_tier2 = $tier2 * $commodity_new_tier2; $newrate_tier3 = $tier3 * $commodity_new_tier3; $current_tier1 = $tier1 * $commodity_current_tier1; $current_tier2 = $tier2 * $commodity_current_tier2; $current_tier3 = $tier3 * $commodity_current_tier3; } if ($CLASS == "M") { $newrate_tier1 = $UNITS * $commodity_new_multi; $current_tier1 = $UNITS * $commodity_current_multi; $newrate_tier2 = 0; $current_tier2 = 0; $newrate_tier3 = 0; $current_tier3 = 0; } if ($CLASS == "C") { $newrate_tier1 = $UNITS * $commodity_new_comm; $current_tier1 = $UNITS * $commodity_current_comm; $newrate_tier2 = 0; $current_tier2 = 0; $newrate_tier3 = 0; $current_tier3 = 0; } if ($CLASS == "RC") { $newrate_tier1 = $UNITS * $commodity_new_rec; $current_tier1 = $UNITS * $commodity_current_rec; $newrate_tier2 = 0; $current_tier2 = 0; $newrate_tier3 = 0; $current_tier3 = 0; } if (empty($PUMPZONE)) { $newrate_pumpzone = 0; $current_pumpzone = 0; } if ($PUMPZONE == "1") { $newrate_pumpzone = 0; $current_pumpzone = 0; } if ($PUMPZONE == "2") { $newrate_pumpzone = $UNITS * $pumpzone_new_zone2; $current_pumpzone = $UNITS * $pumpzone_current_zone2; } if ($PUMPZONE == "3") { $newrate_pumpzone = $UNITS * $pumpzone_new_zone3; $current_pumpzone = $UNITS * $pumpzone_current_zone3; } if ($current_tier1>0){ $diff_tier1 = $newrate_tier1 - $current_tier1; $percent_tier1 = ($diff_tier1 / $current_tier1) * 100; } if ($current_tier2>0) { $diff_tier2 = $newrate_tier2 - $current_tier2; $percent_tier2 = ($diff_tier2 / $current_tier2) * 100; } if ($current_tier3>0) { $diff_tier3 = $newrate_tier3 - $current_tier3; $percent_tier3 = ($diff_tier3 / $current_tier3) * 100; } $diff_pumpzone = $newrate_pumpzone - $current_pumpzone; $total_new = $newrate_tier1 + $newrate_tier2 + $newrate_tier3 + $newrate_pumpzone; $total_current = $current_tier1 + $current_tier2 + $current_tier3 + $current_pumpzone; $total_diff = $diff_tier1 + $diff_tier2 + $diff_tier3 + $diff_pumpzone; if ($total_percent>0) { $total_percent = ($total_diff / $total_current) * 100; } if ($current_pumpzone>0) { $percent_pumpzone = ($diff_pumpzone / $current_pumpzone) * 100; } if ($diff_pumpzone<=0) { $current_pumpzone=0; $percent_pumpzone=0; } if ($_POST['UNITS']>0 && $_POST['PUMPZONE']>0 && $_POST['METERSIZE']>0) { $baserate_diff = $baserate_new - $baserate_current; $baserate_percent = ($baserate_diff / $baserate_current) * 100; $monthly_new = $total_new + $baserate_new; $monthly_current = $total_current + $baserate_current; $monthly_diff = $total_diff + $baserate_diff; $monthly_percent = ($monthly_diff / $monthly_current) * 100; } else { $baserate_new = ''; $baserate_current = ''; } if ($CLASS == "R") {$CLASS = "Residential";} if ($CLASS == "M") {$CLASS = "Multi-Family";} if ($CLASS == "C") {$CLASS = "COMM, IND., GOV, IRR";} if ($CLASS == "RC") {$CLASS = "Recycled";} ?> <body> <table> <tr> <td> <table> <tr> <td style="background-color:#9eb3cb !important;">Estimated Monthly Bill</td> <td style="background-color:#9eb3cb !important;">New Rate</td> <td style="background-color:#9eb3cb !important;">Current Rate</td> <td style="background-color:#9eb3cb !important;">Difference</td> <td style="background-color:#9eb3cb !important;">%</td> </tr> <tr> <td>Tier I &nbsp;&nbsp;&nbsp;&nbsp;(0-12)</td> <td align=right><? if ($newrate_tier1>0){ echo"$"; echo number_format($newrate_tier1,2,'.',',');} else {echo"-";} ?></td> <td align=right><? if ($current_tier1>0){ echo"$"; echo number_format($current_tier1,2,'.',',');} else {echo"-";} ?></td> <td align=right><? if ($diff_tier1>0){ echo"$"; echo number_format($diff_tier1,2,'.',',');} else {echo"-";} ?></td> <td align=right><? if ($percent_tier1>0){ echo number_format($percent_tier1,2,'.',',');echo"%"; } else {echo"-";} ?></td> </tr> <tr> <td>Tier II &nbsp;&nbsp;&nbsp;(13-39)</td> <td align=right><? if ($newrate_tier2>0){ echo"$"; echo number_format($newrate_tier2,2,'.',',');} else {echo"-";} ?></td> <td align=right><? if ($current_tier2>0){ echo"$"; echo number_format($current_tier2,2,'.',',');} else {echo"-";} ?></td> <td align=right><? if ($diff_tier2>0){ echo"$"; echo number_format($diff_tier2,2,'.',',');} else {echo"-";} ?></td> <td align=right><? if ($percent_tier2>0){ echo number_format($percent_tier21,2,'.',',');echo"%"; } else {echo"-";} ?></td> <tr> <td >Tier III &nbsp;&nbsp;(40+)</td> <td align=right><? if ($newrate_tier3>0){ echo"$"; echo number_format($newrate_tier3,2,'.',',');} else {echo"-";} ?></td> <td align=right><? if ($current_tier3>0){ echo"$"; echo number_format($current_tier3,2,'.',',');} else {echo"-";} ?></td> <td align=right><? if ($diff_tier3>0){ echo"$"; echo number_format($diff_tier3,2,'.',',');} else {echo"-";} ?></td> <td align=right><? if ($percent_tier3>0){ echo number_format($percent_tier3,2,'.',',');echo"%"; } else {echo"-";} ?></td> </tr> <tr> <td>Pump Zone</td> <td align=right><? if ($newrate_pumpzone>0){ echo"$"; echo number_format($newrate_pumpzone,2,'.',',');} else {$newrate_pumpzone='-';} ?></td> <td align=right><? if ($current_pumpzone){ echo"$"; echo number_format($current_pumpzone,2,'.',',');} else {$current_pumpzone='-';} ?></td> <td align=right><? if ($diff_pumpzone>0){ echo"$"; echo number_format($diff_pumpzone,2,'.',',');} else {echo"-";} ?></td> <td align=right><? if ($percent_pumpzone>0){ echo number_format($percent_pumpzone,2,'.',',');echo"%"; } else {echo"-";} ?></td> </tr> <tr> <td>Total Commodity Charges</td> <td align=right><? if ($total_new>0){ echo"$"; echo number_format($total_new,2,'.',',');} else {$total_new='-';} ?></td> <td align=right><? if ($total_current>0){ echo"$"; echo number_format($total_current,2,'.',',');} else {$total_current='-';} ?></td> <td align=right><? if ($total_diff>0){ echo"$"; echo number_format($total_diff,2,'.',',');} else {$total_diff='-';} ?></td> <td align=right><? if ($total_percent>0){ echo number_format($total_percent,2,'.',',');echo"%"; } else {$total_percent='-';} ?></td> </tr> <tr> <td>Base Rate</td> <td align=right><? if ($baserate_new>0){ echo"$"; echo number_format($baserate_new,2,'.',',');} else {echo"-";} ?></td> <td align=right><? if ($baserate_current>0){ echo"$"; echo number_format($baserate_current,2,'.',',');} else {echo"-";} ?></td> <td align=right><? if ($baserate_diff>0){ echo"$"; echo number_format($baserate_diff,2,'.',',');} else {echo"-";} ?></td> <td align=right><? if ($baserate_percent>0){ echo number_format($baserate_percent,2,'.',',');echo"%"; } else {echo"-";} ?></td> </tr> <tr> <td>Total Month Charges</td> <td align=right><? if ($monthly_new>0){ echo"$"; echo number_format($monthly_new,2,'.',',');} else {echo"-";} ?></td> <td align=right><? if ($monthly_current>0){ echo"$"; echo number_format($monthly_current,2,'.',',');} else {echo"-";} ?></td> <td align=right><? if ($monthly_diff>0){ echo"$"; echo number_format($monthly_diff,2,'.',',');} else {echo"-";} ?></td> <td align=right><? if ($monthly_percent>0){ echo number_format($monthly_percent,2,'.',',');echo"%"; } else {echo"-";} ?></td> </tr> </table> </td> </tr> </table>

This is an error 404

There are `0` results


preferences:
1565.73 ms | 1398 KiB | 21 Q