News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Suggestions please....if any (birthdate mod)

Started by SeaOfSin, July 08, 2005, 01:25:23 AM

Previous topic - Next topic

SeaOfSin

I have written from ideas on this forum of a modification to birthdates. It is basically similar to the Vb (I think) registration for drop down menu options and was just wondering if there is anything I should change or improve.  Check out the code here.

Register.php
Find

$_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']);


Add after

if (strtr($_POST['birthdate'], array('-' => '')) > strftime('%Y-%m-%d', time() - 3600 * 24 * 365 * 18))
fatal_error('Sorry, you must be at least 18 years old to register.', false);
            if (!isset($_POST['birthdate']) || $_POST['birthdate'] == '')
fatal_error('Please enter date of birth to register.', false);

or any other age

Register.template.php
Find

<td>
<input type="password" name="passwrd2" size="30" tabindex="', $context['tabindex']++, '" />
</td>
</tr>';


Replace

<input type="password" name="passwrd2" size="30" tabindex="', $context['tabindex']++, '" />
</td>
</tr>

<tr>
<td width="40%">
<b>', $txt[563], ':</b>
<div class="smalltext">', $txt[565], ' - ', $txt[564], ' - ', $txt[566], '</div>
</td>
<td class="smalltext">
<select name="bday2">;
<option value="" selected="selected">', $txt['bdday'], '</option>';
foreach ($txt['bddays'] as $bdday)
echo '
<option value="', $bdday, '" ', $context['member']['birth_date']['day'], ';">', $bdday, '</option>';

echo '
</select>

<select name="bday1">;
<option value="" selected="selected">', $txt['bdmonth'], '</option>';
foreach ($txt['bdmonths'] as $bdmonth)
echo '
<option value="', $bdmonth, '" ', $context['member']['birth_date']['month'], ';">', $bdmonth, '</option>';

echo '
</select>

<select name="bday3">;
<option value="" selected="selected">', $txt['bdyear'], '</option>';
foreach ($txt['bdyears'] as $bdyear)
echo '
<option value="', $bdyear, '" ', $context['member']['birth_date']['year'], ';">', $bdyear, '</option>';

echo '
</select>
</td>
</tr>';


Profile.template

Find:

<tr>
<td width="40%">
<b>', $txt[563], ':</b>
<div class="smalltext">', $txt[566], ' - ', $txt[564], ' - ', $txt[565], '</div>
</td>
<td class="smalltext">
<input type="text" name="bday3" size="4" maxlength="4" value="', $context['member']['birth_date']['year'], '" /> -
<input type="text" name="bday1" size="2" maxlength="2" value="', $context['member']['birth_date']['month'], '" /> -
<input type="text" name="bday2" size="2" maxlength="2" value="', $context['member']['birth_date']['day'], '" />
</td>
</tr>


Replace


<tr>
<td width="40%">
<b>', $txt[563], ':</b>
<div class="smalltext">', $txt[565], ' - ', $txt[564], ' - ', $txt[566], '</div>
</td>
<td class="smalltext">
<select name="bday2">;
<option value="', $context['member']['birth_date']['day'], '" selected="selected">', $context['member']['birth_date']['day'], '</option>';
foreach ($txt['bddays'] as $bdday)
echo '
<option value="', $bdday, '" ', $context['member']['birth_date']['day'], ';">', $bdday, '</option>';

echo '
</select>

<select name="bday1">;
<option value="', $context['member']['birth_date']['month'], '" selected="selected">', $context['member']['birth_date']['month'], '</option>';
foreach ($txt['bdmonths'] as $bdmonth)
echo '
<option value="', $bdmonth, '" ', $context['member']['birth_date']['month'], ';">', $bdmonth, '</option>';

echo '
</select>

<select name="bday3">;
<option value="', $context['member']['birth_date']['year'], '" selected= "selected">', $context['member']['birth_date']['year'], '</option>';
foreach ($txt['bdyears'] as $bdyear)
echo '
<option value="', $bdyear, '" ', $context['member']['birth_date']['year'], ';">', $bdyear, '</option>';

echo '
</select>

</td>
</tr>


Profile.english

Find

?>


Replace


$txt['bdyear'] = 'Year';
$txt['bdyears'] = array
(
'1935',
'1936',
'1937',
'1938',
'1939',
'1940',
'1941',
'1942',
'1943',
'1944',
'1945',
'1946',
'1947',
'1948',
'1949',
'1950',
'1951',
'1952',
'1953',
'1954',
'1955',
'1956',
'1957',
'1958',
'1959',
'1960',
'1961',
'1962',
'1963',
'1964',
'1965',
'1966',
'1967',
'1968',
'1969',
'1970',
'1971',
'1972',
'1973',
'1974',
'1975',
'1976',
'1977',
'1978',
'1979',
'1980',
'1981',
'1982',
'1983',
'1984',
'1985',
'1986',
'1987',
'1988',
'1989',
'1990',
'1991',
'1992',
'1993',
'1994',
'1995',
'1996',
'1997',
'1998',
'1999',
'2000',
);
$txt['bdmonth'] = 'Month';
$txt['bdmonths'] = array
(
'01',
'02',
'03',
'04',
'05',
'06',
'07',
'08',
'09',
'10',
'11',
'12',
);
$txt['bdday'] = 'Day';
$txt['bddays'] = array
(
'01',
'02',
'03',
'04',
'05',
'06',
'07',
'08',
'09',
'10',
'11',
'12',
'13',
'14',
'15',
'16',
'17',
'18',
'19',
'20',
'21',
'22',
'23',
'24',
'25',
'26',
'27',
'28',
'29',
'30',
'31',
);
?>


I think thats all of it....If I remember correctly. :)

Is there any improvements that can be made of is that good?

Also if you like it please feel free to use it

Thanks in advance

Sea Of Sin

drroot


Advertisement: