FOLLOW US!

Pregananant

Oh no. Something must be wrong.
You’ve been having a sudden craving of pickles and romantic comedies, and that tummy looks like it’s not just post-thanksgiving or Christmas feast.
You fear the worst: “I am gregnant”.
But let’s not assume things! It doesn’t have to necessarily mean that you are pergant; you could just be a bit bloated from eating so many damn, delicious cupcakes! Not every cheat meal is pargency; which is why you are going to check this with a magic thing called time (because going to the doctor’s appointment may just send you to bankruptcy..)
Make a function called pregananant which tests times from the current date since you.. uh….. held hands.
  • If it’s been more than 9 months: congrats, you are not progent! Or you are carrying a super human.. in which case, congrats again!! I think..
  • If it’s been anywhere from 1 to 9 months.. oh no! You could very well be prangnet! Check with your doctor!
  • If it’s been 1 month or less, there may not be any reason to panic. Wait a bit more to see if you are really bregant.
  • And if you are testing for time in the future… then you have much bigger issues to worry about. But, hey, at least you are not prreganté!
        <?php 
        include("validations.php");
        function form_creator($form_id, $form_innertext, $array_of_inputs){
            $output = "<form method = 'GET' action = '".$_SERVER["PHP_SELF"]."' id = 'form.$form_id.' class = 'form-questionnaire'>";
                $output .= "<h2 class = 'form-innertext'>$form_innertext</h2>";
                foreach($array_of_inputs as $arr):
                    $output .= "<div class = 'form-inputs'>";
                        $output .= $arr[0]." <input type = '".$arr[1]."' id = '".$arr[2]."' name = '".$arr[3]."' />";
                    $output .= "</div>";
                endforeach;
                $output .= "<div class = \"form-submit\">";
                    $output .= "<input type = \"submit\" name = \"btnForward\" id = \"btnForward\" value = \"CONTINUE\"/>";
                $output .= "</div>";
            $output .= "</form>";
        
            return $output;
        }
        
        function user_validations($arr){
            $get_params = array_keys($_GET);
            foreach($arr as $ar):
                for($i = 0; $i < count($get_params) - 1; $i++){
                    if($ar[2] == $get_params[$i]){
                        check_validations($ar[0], $get_params[$i]);
                    }
                }
            endforeach;
            */
            for ($i = 0; $i < count($arr); $i++){
                foreach($_GET as $key => $value){
                    /* if ($key == $arr[$i]){
                         check_validations();
                     } */
                    echo $key;
                    echo "<hr/>";
                    echo $value;
                    echo "<hr/>";
                    echo $arr[$i][2];
                 }
            } 
        }
        
        function check_validations($field_label, $get_field_value){
            $field_value = $_GET[$get_field_value];
            $current_year = date("Y");
            $time = strtotime($current_year);
            if($field_value == ""){
                echo "The field ".$field_label." is empty..<br/>";
            }
            switch($get_field_value):
                case "email":
                    email_validation($field_value, $field_label);
                    break;
                case "firstname":
                    first_name_validation($field_value, $field_label);
                    if(strlen($field_value) < 2):
                        echo "The field ".$field_label." cannot have less than 2 letters!<br/>";
                    endif;
                    if(strlen($field_value) > 30):
                        echo "The field ".$field_label." cannot have more than 30 letters!<br/>";
                    endif;
                    break;
                case "lastname":
                    last_name_validation($field_value, $field_label);
                    if(strlen($field_value) < 2):
                        echo "The field ".$field_label." cannot have less than 2 letters!<br/>";
                    endif;
                    if(strlen($field_value) > 30):
                        echo "The field ".$field_label." cannot have more than 30 letters!<br/>";
                    endif;
                    break;
                case "birth_day":
                    birth_day_validation($field_value, $field_label);
                    if($field_value < 0):
                        echo "The field ".$field_label." cannot be less than 0!<br/>";
                    endif;
                    if($field_value > 31):
                        echo "The field ".$field_label." cannot be more than 31!<br/>";
                    endif;
                    break;
                case "birth_month":
                    birth_month_validation($field_value, $field_label);
                    if($field_value < 0):
                        echo "The field ".$field_label." cannot be less than 0!<br/>";
                    endif;
                    if($field_value > 12):
                        echo "The field ".$field_label." cannot be more than 12!<br/>";
                    endif;
                    break;
                case "birth_year":
                    birth_year_validation($field_value, $field_label);
                    if($field_value < 0):
                        echo "The field ".$field_label." cannot be less than 0!<br/>";
                    endif;
                    if($field_value > date("Y")):
                        echo "The field ".$field_label." cannot be more than ".date("Y")."!<br/>";
                    endif;
                    break;
            endswitch; 
        }
        
        $user_email = array(
            array("Email", "text", "email", "email"),
        );
        $user_names = array(
            array("First Name", "text", "firstname", "firstname"),
            array("Last Name", "text", "lastname", "lastname")
        );
        $user_age = array(
            array("Day", "number", "birth_day", "birth_day"),
            array("Month", "number", "birth_month", "birth_month"),
            array("Year", "number", "birth_year", "birth_year"),
        );
        
        $form_array = array(
            array("form" => form_creator("Email", "Hey there, what's your email?", $user_email), "field_data" => $user_email),
            array("form" => form_creator("Names", "And your name is..?", $user_names), "field_data" => $user_names),
            array("form" => form_creator("Age", "Cool! How old are you?", $user_age), "field_data" => $user_age)
        );
        
        foreach($form_array as $arr){
            echo $arr["form"];
            user_validations($arr["field_data"]);
        }
        ?>

        1 thought on “Pregananant”

        Leave a Reply

        Scroll to Top