<?php
//connecting to database.
$conn = mysqli_connect('localhost','hutbnosp_dsdgnsu','z1i#$_;+L2?U','hutbnosp_dsdgns') or die("Error: Can not connect to database");
//if button with the name submit has been clicked
if(isset($_POST['submit'])){
//declaring variables
    $gender = $_POST['gender'];
    $age = $_POST['age'];
    $country = $_POST['country'];
    $age = $_POST['age'];
    
    $fever = $_POST['fever'];
    
    $symptom1 = $_POST['symptom1'];
    $symptom2 = $_POST['symptom2'];
    $symptom3 = $_POST['symptom3'];
    $symptom4 = $_POST['symptom4'];
    $symptom5 = $_POST['symptom5'];
    $symptom6 = $_POST['symptom6'];
    $symptom7 = $_POST['symptom7'];
    $symptom8 = $_POST['symptom8'];
    $symptom9 = $_POST['symptom9'];
    $symptom10 = $_POST['symptom10'];
    $symptom11 = $_POST['symptom11'];
    $symptom12 = $_POST['symptom12'];
    $symptom13 = $_POST['symptom13'];
    $symptom14 = $_POST['symptom14'];
    $symptom15 = $_POST['symptom15'];
    $symptom16 = $_POST['symptom16'];
    $symptom17 = $_POST['symptom17'];
    $symptom18 = $_POST['symptom18'];
    $symptom19 = $_POST['symptom19'];
    
    $symptom20 = $_POST['symptom20'];
    $symptom21 = $_POST['symptom21'];
    $symptom22 = $_POST['symptom22'];
    
    $symptom23 = $_POST['symptom23'];
    $symptom24 = $_POST['symptom24'];
    $symptom25 = $_POST['symptom25'];
    $symptom26 = $_POST['symptom26'];
    
    
    
    $resistance1 = $_POST['resistance1'];
    $resistance2 = $_POST['resistance2'];
    $resistance3 = $_POST['resistance3'];
    $resistance4 = $_POST['resistance4'];
    $resistance5 = $_POST['resistance5'];
    $resistance6 = $_POST['resistance6'];
    $resistance7 = $_POST['resistance7'];
    $resistance8 = $_POST['resistance8'];
    $resistance9 = $_POST['resistance9'];
    
    $resistance10 = $_POST['resistance10'];
    $resistance11 = $_POST['resistance11'];
    $resistance12 = $_POST['resistance12'];
    $resistance13 = $_POST['resistance13'];
    $resistance14 = $_POST['resistance14'];
    
    $resistance15 = $_POST['resistance15'];
    $resistance16 = $_POST['resistance16'];
    
    $resistance17 = $_POST['resistance17'];
    
    //calculating values
    $corona2= $symptom1+$symptom3+$symptom4+$symptom5+$symptom6+$symptom7+$symptom8+$symptom20+$symptom21+$symptom22;
    $dengue2= $symptom1+$symptom9+$symptom10+$symptom11+$symptom12+$symptom13+$symptom14+$symptom15+$symptom16+$symptom23+$symptom24+$symptom25+$symptom26;
    $swine_flu2= $symptom1+$symptom2+$symptom4+$symptom6+$symptom7+$symptom8+$symptom9+$symptom10+$symptom11+$symptom12+$symptom17;
    $viral_fever2= $symptom1+$symptom2+$symptom9+$symptom11+$symptom12+$symptom13+$symptom18+$symptom19;
    
    
    $res_corona=round((($resistance1+$resistance2+$resistance3+$resistance10+$resistance11+$resistance12+$resistance13+$resistance14)/8)*100,2);
    $res_dengue=round((($resistance6+$resistance7+$resistance8+$resistance9+$resistance15+$resistance16)/6)*100,2);
    $res_swine_flu=round((($resistance1+$resistance2+$resistance4+$resistance5+$resistance11+$resistance17)/6)*100,2);
    $res_viral_fever=round((($resistance1+$resistance2+$resistance3)/3)*100,2);
    
    if($fever==2){
        $corona1=$corona2+1;
    }else {
        $corona1=$corona2;
    }
    
    if($fever==3){
        $dengue1=$dengue2+1;
    }else {
        $dengue1=$dengue2;
    }
    
    if($fever==4){
        $swine_flu1=$swine_flu2+1;
    }else {
        $swine_flu1=$swine_flu2;
    }
    
    if($fever==5){
        $viral_fever1=$viral_fever2+1;
    }else{
        $viral_fever1=$viral_fever2;
    }
    
    $corona= round(($corona1/11)*100,2);
    $dengue= round(($dengue1/14)*100,2);
    $swine_flu= round(($swine_flu1/12)*100,2);
    $viral_fever= round(($viral_fever1/9)*100,2);

    //inserting details (ie image name) in the database
    $conn->query("INSERT INTO test_details (user_gender,user_age,user_country,corona,dengue,swine_flu,viral_fever,res_corona,res_dengue,res_swine_flu,res_viral_fever) VALUES ('$gender','$age','$country','$corona','$dengue','$swine_flu','$viral_fever','$res_corona','$res_dengue','$res_swine_flu','$res_viral_fever')")	or die($mysqli->error());
    
}else{
    header('Location: http://ysibd.com/corona/');
}


?>
<?php
include('includes/header.php');
?>

    <div class="container contact-form">
                    <div class="row">
                        <div class="col-md-12">
                            <h3 style="margin-top:3%;">Results of the online test</h3>
                            
                            <h5 style="text-align:center">Probability of being infected with Novel Coronavirus: <?php echo $corona; ?>%</h5>
                            <div class="progress">
                                <div class="progress-bar bg-danger" role="progressbar" style="width: <?php echo $corona; ?>%" aria-valuenow="<?php echo $corona; ?>%" aria-valuemin="0" aria-valuemax="100"></div>
                            </div>
                            
                            <h5 style="text-align:center">Probability of getting infected with dengue fever: <?php echo $dengue; ?>%</h5>
                            <div class="progress">
                                <div class="progress-bar bg-info" role="progressbar" style="width: <?php echo $dengue; ?>%" aria-valuenow="<?php echo $dengue; ?>%" aria-valuemin="0" aria-valuemax="100"></div>
                            </div>
                            
                            <h5 style="text-align:center">Probability of getting infected with swine flu: <?php echo $swine_flu; ?>%</h5>
                            <div class="progress">
                                <div class="progress-bar bg-warning" role="progressbar" style="width: <?php echo $swine_flu; ?>%" aria-valuenow="<?php echo $swine_flu; ?>%" aria-valuemin="0" aria-valuemax="100"></div>
                            </div>
                            
                            <h5 style="text-align:center">Probability of getting infected with viral fever: <?php echo $viral_fever; ?>%</h5>
                            <div class="progress">
                                <div class="progress-bar bg-success" role="progressbar" style="width: <?php echo $viral_fever; ?>%" aria-valuenow="<?php echo $viral_fever; ?>%" aria-valuemin="0" aria-valuemax="100"></div>
                            </div>
                            
                            <h3 style="margin-top:10%;">The result of how prepared you are to prevent these diseases</h3>
                            
                            <h5 style="text-align:center">Your Preparation Against Novel Corona: <?php echo $res_corona; ?>%</h5>
                            <div class="progress">
                                <div class="progress-bar bg-danger" role="progressbar" style="width: <?php echo $res_corona; ?>%" aria-valuenow="<?php echo $res_corona; ?>%" aria-valuemin="0" aria-valuemax="100"></div>
                            </div>
                            
                            <h5 style="text-align:center">Your Preparation against Dengue Fever: <?php echo $res_dengue; ?>%</h5>
                            <div class="progress">
                                <div class="progress-bar bg-info" role="progressbar" style="width: <?php echo $res_dengue; ?>%" aria-valuenow="<?php echo $res_dengue; ?>%" aria-valuemin="0" aria-valuemax="100"></div>
                            </div>
                            
                            <h5 style="text-align:center">Your Preparation against Swine Flu: <?php echo $res_swine_flu; ?>%</h5>
                            <div class="progress">
                                <div class="progress-bar bg-warning" role="progressbar" style="width: <?php echo $res_swine_flu; ?>%" aria-valuenow="<?php echo $res_swine_flu; ?>%" aria-valuemin="0" aria-valuemax="100"></div>
                            </div>
                            
                            <h5 style="text-align:center">Your Preparation against Viral Fever: <?php echo $res_viral_fever; ?>%</h5>
                            <div class="progress">
                                <div class="progress-bar bg-success" role="progressbar" style="width: <?php echo $res_viral_fever; ?>%" aria-valuenow="<?php echo $res_viral_fever; ?>%" aria-valuemin="0" aria-valuemax="100"></div>
                            </div>
                            
                            <h3 style="margin-top:10%;">Steps needed to take to prevent these diseases</h3>
                            <div style="padding:3%">
                            <h5 style="font-weight:700;">To prevent Novel Coronovirus:</h5>
                                <ul>
                                    <li>Wash your hands regularly for 20 seconds, with soap and water or alcohol-based hand rub</li>
                                    <li>Cover your nose and mouth with a disposable tissue or flexed elbow when you cough or sneeze</li>
                                    <li>Avoid close contact (1 meter or 3 feet) with people who are unwell</li>
                                    <li>Stay home and self-isolate from others in the household if you feel unwell</li>
                                    <li>Don't Touch your eyes, nose, or mouth if your hands are not clean</li>
                                    <li>Wear a facemask if you are sick</li>
                                    <li>Clean & disinfect surfaces like tables, doorknobs, switches, handles, desks, phones, keyboards, toilets, sinks, etc. which are regularly touched by you</li>
                                    <li>Seek for doctor’s prescription soon if you have fever, cough and difficulty breathing</li>
                                </ul>
                            
                            <h5 style="font-weight:700;">To prevent Dengue Fever:</h5>
                            <p>There is no alternative to keep oneself safe from mosquito biting to prevent Dengue fever. Several measures can be taken to avoid mosquito bites:</p>
                                <ul>
                                    <li>Use long-sleeved shirts and long pants tucked into socks when you are out of home</li>
                                    <li>Use mosquito repellent coils or sprays at your home</li>
                                    <li>Use mosquito repellent cream on your skin</li>
                                    <li>Must use mosquito net during sleeping hours (any time)</li>
                                    <li>Window and door screens are needed to be secure and free of holes</li>
                                    <li>Remain aware about mosquito bites especially early in the morning & dusk</li>
                                    <li>Throw away water from old tires, cans, flower pots, coconut leftovers and any other similar places where rain water can be stored. These are the breeding places for mosquitos</li>
                                    <li>Lemongrass, Holy basil, Citronella etc. mosquito repellent type trees can also be used</li>
                                    <li>If someone in your home gets dengue fever, be especially careful to protect yourself and other family members. Because mosquitoes that bite the infected family member could spread the infection to others in the home</li>
                                    <li>If you develop symptoms of dengue, immediately go to hospital for tests</li>
                                </ul>
                                
                                <h5 style="font-weight:700;">To prevent Swine Flu:</h5>
                                <ul>
                                    <li>Wash your hands with alcohol-based hand rub or soap & water regularly</li>
                                    <li>Cover your nose and mouth with a disposable tissue or flexed elbow when you cough or sneeze.</li>
                                    <li>Avoid crowded places if possible</li>
                                    <li>Do not go to educational institutions, offices or religious places while you are sick</li>
                                    <li>Stay home for at least 24 hours after your fever is gone.</li>
                                    <li>Don't Touch your eyes, nose, or mouth if your hands are not clean</li>
                                    <li>Stay at least 6 feet away from people with flu-like illness</li>
                                </ul>
                                <h5 style="font-weight:700;">To prevent Viral Fever:</h5>
                                <ul>
                                    <li>Wash your hands regularly for 20 seconds, with soap and water or alcohol-based hand rub</li>
                                    <li>Cover your nose and mouth with a disposable tissue or flexed elbow when you cough or sneeze</li>
                                    <li>Avoid close contact with people who are unwell</li>
                                </ul>
                                
                                <a href="https://www.facebook.com/sharer/sharer.php?u=https://syednazmussadat.com/projects/disease-diagnosis"><h3 style="margin-top:10%;">Share with others<i class="fa fa-facebook-square" style="font-size: 40px;margin-left:3%;"></i></h3></a>
                               
                            </div>                            
                        </div>
                        
                    </div>
    </div>
<?php
include('includes/footer.php');
?>