Jump to content
Sign in to follow this  
hs1945

PHP Air Rabatt ifelse

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>

Share this post


Link to post
Share on other sites
<?php
echo "What kind of issue are you having? Mind telling us more whats wrong with the code (expected results and what you are getting)";
?>

 

  • Haha 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...