Re: [Jason] Input Date From Membership Signup Form
Hi Rusty and Jason,
Thanks for this useful post.
I’ve been trying to implement this concept in a membership application and have a few challenges.
1) I’ve got the signup form working with 1 date field called student_1_dob, but I’d ultimately like to use 3 date fields called student_1_dob, student_2_dob, and student_3_dob.
How would change the form code (below) to accommodate the 3 different date fields.
2) How would I implement the same process in my profile update form.
Here’s what I’m using in the member signup viewer for the one date.
In the PHP code at the head of the page:
$student_1_dob = date("m-d-Y",mktime(0,0,0,@$_REQUEST['month'],@$_REQUEST['day'],@$_REQUEST['year']));
$student_1_dob = date("m-d-Y",mktime(0,0,0,@$_REQUEST['month'],@$_REQUEST['day'],@$_REQUEST['year']));
$student_1_dob = date("m-d-Y",mktime(0,0,0,@$_REQUEST['month'],@$_REQUEST['day'],@$_REQUEST['year']));
mysql_query("INSERT INTO `{$TABLE_PREFIX}accounts` SET
student_1_dob = '".mysql_escape($student_1_dob)."',
student_2_dob = '".mysql_escape($student_2_dob)."',
student_3_dob = '".mysql_escape($student_3_dob)."',
... other fields to insert...")
or die("MySQL Error Creating Record:<br/>\n". htmlspecialchars(mysql_error()) . "\n");
$userNum = mysql_insert_id();
And so far, in the input form in the Student 1 area only:
<tr>
<td>Date of Birth</td>
<td><?php
$lowestYear = 1920;
$highestYear = 2006;
?>
Month:
<select name="month">
<?php foreach(range(1,12) as $month): ?>
<option value="<?php echo $month;?>"><?php echo date("F",strtotime("0000-$month"));?></option>
<?php endforeach ?>
</select> Day:
<select name="day">
<?php foreach(range(1,31)as $day): ?>
<option value="<?php echo $day;?>"><?php echo $day;?></option>
<?php endforeach ?>
</select> Year:
<select name="year">
<?php foreach (range($lowestYear,$highestYear) as $year):?>
<option value="<?php echo $year;?>"><?php echo $year;?></option>
<?php endforeach?>
</select>
</tr>
Thanks,
Jerry Kornbluth
The first CMS Builder reference book is now available on-line!
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php