-1

私が取り組んでいる Web サイトの年齢を確認するために、素晴らしく機能するスクリプトを使用しています。現在、ドロップダウン メニューを使用して月、日、年を選択しています。ユーザーが代わりに月、日、年を入力できるようにドロップダウンを変更できることを望んでいました。

コードは次のとおりです。

                <?php

            define('MIN_AGE', 21); // Enter the minimum age that your website visitors must be to view your content (replace 18 with your number)
            define('COOKIE_DAYS', 30); //Enter the number of days you would like the cookie to last (replace 30 with your number)

            // BE CAREFUL EDITING ANYTHING BELOW THIS LINE //

            date_default_timezone_set('America/Los_Angeles');
            function get_birth_drops($year = '', $month = '', $day = '')
            {
                $out = '';

                $year = $year ? $year : '';
                $month = $month ? $month : '';
                $day = $day ? $day : '';

                $month_select = '<label>MM: <select name="bmonth" id="bmonth"><option value=""></option>';
                for($i = 1; $i <=12; $i ++)
                {
                    $selected = ($i == $month) ? ' selected':'';
                    $month_select .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
                }
                $month_select .= '</select></label>';

                $day_select = ' <label>DD: <select name="bday" id="bday"><option value=""></option>';
                for($i = 1; $i <=31; $i ++)
                {
                    $selected = ($i == $day) ? ' selected':'';
                    $day_select .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
                }
                $day_select .= '</select></label>';

                $year_select = ' <label>YYYY: <select name="byear" id="byear"><option value=""></option>';
                for($i = 2010; $i >= 1950; $i --)
                {
                    $selected = ($i == $year) ? ' selected':'';
                    $year_select .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
                }
                $year_select .= '</select></label>';

                $out = $month_select . $day_select . $year_select;

                return $out;
            }

            function calculateAge($birthday){
                return floor((time() - strtotime($birthday))/31556926);
            }
            ?>

何かご意見は?ありがとうございます!

4

2 に答える 2