Jump to content

PHP Air Rabatt ifelse


hs1945
 Share

Recommended Posts

<!DOCTYPE HTML>
<html>
  <head>
    <title>Rabattrechner</title>
    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="css/style.css">
  </head>
  <body>
    <form action="" method="post">
      <select name="anrede">
        <option>Herr</option>
        <option>Frau</option>
      </select>
      <input type="text" name="name" placeholder="Name"><br>
      <input type="text" name="zugeh" placeholder="Zugehörigkeit (Jahre)"><br>
      <input type="text" name="lohn" placeholder="Bruttojahreslohn"><br>
      <input type="submit" value="abschicken"><br>
      <input type="hidden" name="hidden" value="hidden">
    </form>
    <?php
    $cars = array('keines','Mittelklasse','gehobene Klasse','S Klasse');
        echo $_POST['anrede'] . " " . $_POST['name'];
        echo "<br>Zugehörigkeit: " . $_POST['zugeh'] . " Jahre";
        echo "<br>Gehalt: " . $_POST['lohn'] . "€";
    
    if ($_POST['zugeh'] >= "5" && $_POST['zugeh'] < "15")
    {
        echo "<br>Fahrzeug: " . $cars[1];
        echo "<br>Zuschuss: " . $_POST['lohn']*0.1 . "€"; 
    }
    
    elseif ($_POST['zugeh'] >= "15" && $_POST['zugeh'] < "20")
    {
        echo "<br>Fahrzeug: " . $cars[2];
        echo "<br>Zuschuss: " . $_POST['lohn']*0.13 . "€"; 
    }
    
    elseif ($_POST['zugeh'] >= "20" )
    {
        echo "<br>Fahrzeug: " . $cars[3];
        echo "<br>Zuschuss: " . $_POST['lohn']*0.17 . "€";
        $zus=$_POST['lohn']*0.17+2000 . "€"; 
        
        echo "<br>Zuschuss mit Einmalzahlung von 2000€: " . $zus;
    }
    
    else
    {
        echo "<br>Fahrzeug: " . $cars[0];
    }
    ?>
  </body>
</html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...