Calorie Calculator PHP

Words
87
Reading
1 min
Listen
Play
9y

Hello guys my name is Sinan Karayaman. I have been working on wordpress and other web services for few years now.

This program coded for calorie calculator, with calorie calculation script you can calculate your calories very simply with the help of form labels. I explain below in order to help you explain the functions used in the script.

  • isset : Determine if a variable is set and is not NULL

fuctions.php

<?php
            /*
                Sinan KARAYAMAN
            */

                if(isset($_POST['Yas']) && isset($_POST['Kilo']) && isset($_POST['Boy'])){


                    $Yas=$_POST['Yas'];
                    $Kilo=$_POST['Kilo'];
                    $Boy = $_POST['Boy'];
                    $cinsiyet=$_POST['cinsiyet'];

                    switch ($cinsiyet){

                        case 'Female':
                            $cinsiyet= 655 + (9.6 * $Kilo ) + (1.8 * $Boy) - (4.7 * $Yas);
                            echo "

Tahmini günlük metabolizma hızınız $cinsiyet

"
; echo "

Bu şu anki kilonuzu korumak için günde kabaca $cinsiyet kaloriye ihtiyacınız olduğu anlamına gelir.

"
; break; case 'Male': $cinsiyet=66 + (13.7 *$Kilo) + (5 * $Boy) - (6.8 * $Yas); echo "

Tahmini günlük metabolizma hızınız : $cinsiyet

"
; echo "

Bu şu anki kilonuzu korumak için günde kabaca $cinsiyet kaloriye ihtiyacınız olduğu anlamına gelir.

"
; break; } } ?>

index.php


<!DOCTYPE html>
<html>
<head>
    <title>KALORI HESAPLAMA</title>
    <style type="text/css">
        *{
            font-family: arial;
            color: #666;
        }
    </style>
</head>
<body>

    <center>
        <h2>KALORI HESAPLAMA</h2>
        <form action="functions.php" method="post">

            Cinsiyeti Seçin:<br />
            <select name="cinsiyet" style="padding: 5px; width: 265px; border-radius: 3px; border: 1px solid #ddd;"><br />
                <option value="Male">Erkek</option>
                <option value="Female">Kadin</option>
            </select><br /><br />

            <input name="Yas" type="text" placeholder="Yaşınızı Girin" style="padding: 5px; width: 250px; border-radius: 3px; border: 1px solid #ddd;" /><br /><br />
            <input name="Kilo" type="text" placeholder="Kilonuzu Girin" style="padding: 5px; width: 250px; border-radius: 3px; border: 1px solid #ddd;" /><br /><br />
            <input name="Boy" type="text" placeholder="Boyunuzu Girin" style="padding: 5px; width: 250px; border-radius: 3px; border: 1px solid #ddd;" /><br /><br />
            <input type="Submit" value="HESAPLA" style="padding: 10px 5px; width: 265px; border-radius: 3px; border: 1px dashed #ddd; background-color: white;" />


            

        </form>

    </center>

</body>
</html>

  • Result

1 kalori.png

Github url : https://github.com/sinankarayaman/Kalori-Hesaplama



Posted on Utopian.io - Rewarding Open Source Contributors

Calorie Calculator PHP | Ecency