Jump to content
Sign in to follow this  
davestacey

dob dropdown

Recommended Posts

Hi,

 

i installed the contribution "dropdown for dob". as the title says it adds a drop down for the date of birth on the create_account.php page.

 

This works no problem when creating an account, however, if someone signs up with a duplicate email address, it then produces this error...

 

 

Date of Birth: 
Fatal error: [] operator not supported for strings in /home/buzzshop/public_html/create_account.php on line 378

 

 

 

The line it refers to is:

 

 

              <td class="main">
              <?php
              
              for ($i=1; $i<32; $i++) {
line378:             $dob_day[] = array('id' => sprintf('%02d', $i), 'text' => sprintf('%02d', $i));
           }
           
  for ($i=1; $i<13; $i++) {
  $dob_month[] = array('id' => sprintf('%02d', $i), 'text' => strftime('%B',mktime(0,0,0,$i,1,2000)));
  }

  $today = getdate();
  $first_year = $today['year'] - 77; 
  $last_year = $today['year'] - 10;
  for ($i=$first_year; $i < $last_year; $i++) {
  $dob_year[] = array('id' => sprintf('%02d', $i), 'text' => sprintf('%02d', $i));
  }

              
  echo tep_draw_pull_down_menu('dob_day', $dob_day);
  echo tep_draw_pull_down_menu('dob_month', $dob_month);
  echo tep_draw_pull_down_menu('dob_year', $dob_year);
                              echo tep_not_null(ENTRY_DATE_OF_BIRTH_TEXT) ? '<span class="inputRequirement">' . ENTRY_DATE_OF_BIRTH_TEXT . '</span>': '';
              ?>
              </td>

 

 

 

 

that code replaced this original code in the create_account.php page, which was:

 

 

 

<!-- <td class="main"><?php echo tep_draw_input_field('dob') . ' ' . (tep_not_null(ENTRY_DATE_OF_BIRTH_TEXT) ? '<span class="inputRequirement">' . ENTRY_DATE_OF_BIRTH_TEXT . '</span>': ''); ?></td> -->

 

 

 

 

this is a link to the contribution http://www.oscommerce.com/community/contributions,1547

 

Can anyone help me find out whats going wrong please?

Share this post


Link to post
Share on other sites

wow.. what a powerful and useful search function is it!!!

 

I just installed the same contribution and have the same error..

 

But, in my case, my default country setting is United States and this is

 

the only option for the country.. By miskate, I clicked that box and put it as

 

"Select" As soon as I changed it, it showed me the same error message..

 

What's wrong with this? Any idea will be helpful.

 

 

 

jjanguda

Share this post


Link to post
Share on other sites

I've been having the same problems. My server doesn't print the error messages to the screen, so I never know what the problem was until now. After reading your error message, I found a solution to the problem:

replace

<?php
            
             for ($i=1; $i<32; $i++) {
line378:             $dob_day[] = array('id' => sprintf('%02d', $i), 'text' => sprintf('%02d', $i));
          }
          
 for ($i=1; $i<13; $i++) {
 $dob_month[] = array('id' => sprintf('%02d', $i), 'text' => strftime('%B',mktime(0,0,0,$i,1,2000)));
 }

 $today = getdate();
 $first_year = $today['year'] - 77;
 $last_year = $today['year'] - 10;
 for ($i=$first_year; $i < $last_year; $i++) {
 $dob_year[] = array('id' => sprintf('%02d', $i), 'text' => sprintf('%02d', $i));
 }

            
 echo tep_draw_pull_down_menu('dob_day', $dob_day);
 echo tep_draw_pull_down_menu('dob_month', $dob_month);
 echo tep_draw_pull_down_menu('dob_year', $dob_year);
                             echo tep_not_null(ENTRY_DATE_OF_BIRTH_TEXT) ? '<span class="inputRequirement">' . ENTRY_DATE_OF_BIRTH_TEXT . '</span>': '';
             ?>

with

<?php
            
for ($i=1; $i<32; $i++) {
 $dob_day_arr[] = array('id' => sprintf('%02d', $i), 'text' => sprintf('%02d', $i));
}
          
for ($i=1; $i<13; $i++) {
 $dob_month_arr[] = array('id' => sprintf('%02d', $i), 'text' => strftime('%B',mktime(0,0,0,$i,1,2000)));
}

$today = getdate();
$first_year = $today['year'] - 77;
$last_year = $today['year'] - 10;
for ($i=$first_year; $i < $last_year; $i++) {
 $dob_year_arr[] = array('id' => sprintf('%02d', $i), 'text' => sprintf('%02d', $i));
}

            
echo tep_draw_pull_down_menu('dob_day', $dob_day_arr);
echo tep_draw_pull_down_menu('dob_month', $dob_month_arr);
echo tep_draw_pull_down_menu('dob_year', $dob_year_arr);
                             echo tep_not_null(ENTRY_DATE_OF_BIRTH_TEXT) ? '<span class="inputRequirement">' . ENTRY_DATE_OF_BIRTH_TEXT . '</span>': '';
             ?>

What I did was replace the arrays dob_day[], dob_month[] and dob_year[] with arrays by the same name with the suffix _arr. The reason for this, is that when the page calls for itself (as it does if the email address exists), it receives variables from your browser by the same names as the arrays. The error you got tells us that it can't turn a string variable into an array. It was trying to, because they have the same name. So giving the arrays a new, distinguishing name, solved the problem.

You can replace your code with the one I put here. I'll ad a new version to the contribution for the next generations.

 

-Ethan, doing my share.

Share this post


Link to post
Share on other sites

I've intergrated this contribution into my store and it works great. The only problem is that I also have Purchase without account and if a customer want to go down that route and not create an account. the drop down date of birth dosn't show up when the page requesting customer details comes up.

 

Has anyone managed to get dropdown DOB working with PWA????

 

Any help would be much appreciated thanks. If you need me to post any code from PWA please let me know.

Share this post


Link to post
Share on other sites

How would I change the year range on this? Currently, it says 1928 - 1987. While I don't have any customers born before 1928, I do have a few born after 1987.

 

Thanks!

Joe

Share this post


Link to post
Share on other sites

great and easily installed. thanks.

how can i make th month appear as numbers, not letters? i.e: December becomes 12 etc...

Share this post


Link to post
Share on other sites

@ jderouen

modify the following to suit your needs:

$first_year = $today['year'] - 77;

$last_year = $today['year'] - 17;

the first line will take todays date and subtract 77 years from it.

the second one will subtract 17 years from today.

Share this post


Link to post
Share on other sites

Very nice, compact addon module.

Props to the creator, and subsequently revisors that fixed up the install instructions.

 

Good work+

Share this post


Link to post
Share on other sites
Neat Contrib - thanks for the quick fix to a standard problem!!

 

regards,

 

HL

hi

 

it may be a neat contribution BUT what happens if some wally selects 31 February ?

 

it allows that date to go through... any way to block that?

 

thanks


Upon receiving fixes and advice, too many people don't bother to post updates informing the forum of how it went. Until of course they need help again on other issues and they come running back!

 

Why receive the information you require in good faith for free, only to then have the attitude to ignore the people who gave it to you?

 

There's no harm in saying, 'Thanks, it worked'. On the contrary, it creates a better atmosphere.

 

CHOOCH

Share this post


Link to post
Share on other sites

It is indeed a usefull contribution. I also made the modifications to the order_info.php file (because I have purchase without account and fast easy chechout, so when a guest wants to proceed to checkout he'll fill a form and have an account created) and to the account_edit.php file, where users will end up if they want to change their detailes. But here is not enough to just modify the file, because everytime you go to "change account information" the data shown will be the default one (which is not important when new accounts are about to be created), but if you already have a date set, it will not be shown. So, after you make the modifications from the contrib, at the second step where you are supposed to replace one line

<td class="main"><?php echo tep_draw_input_field('dob') . ' ' . (tep_not_null(ENTRY_DATE_OF_BIRTH_TEXT) ? '<span class="inputRequirement">' . ENTRY_DATE_OF_BIRTH_TEXT . '</span>': ''); ?></td>

with block (I added line numbers to explain better the modifications):

1.			   <td class="main">
2.				<?php
3.		for ($i=1; $i<32; $i++) {
4.			$dob_day_arr[] = array('id' => sprintf('%02d', $i), 'text' => sprintf('%02d', $i));
5.		}
6.		for ($i=1; $i<13; $i++) {
7.			$dob_month_arr[] = array('id' => sprintf('%02d', $i), 'text' => strftime('%B',mktime(0,0,0,$i,1,2000)));
8.		}
9.		$today = getdate();
10.		$first_year = $today['year'] - 77; 
11.		$last_year = $today['year'] - 17;
12.		for ($i=$first_year; $i < $last_year; $i++) {
13.			$dob_year_arr[] = array('id' => sprintf('%02d', $i), 'text' => sprintf('%02d', $i));
14.		}
15.		echo tep_draw_pull_down_menu('dob_day', $dob_day_arr);
16.		echo tep_draw_pull_down_menu('dob_month', $dob_month_arr);
17.		echo tep_draw_pull_down_menu('dob_year', $dob_year_arr);
18.		echo tep_not_null(ENTRY_DATE_OF_BIRTH_TEXT) ? '<span class="inputRequirement">' . ENTRY_DATE_OF_BIRTH_TEXT . '</span>': '';
19.				?>
20.				</td>

 

Before line 15 add the following code:

						 $s_dob = $account['customers_dob'];
					 $dob_year = substr($s_dob, 0, 4);
					 $dob_month = substr($s_dob, 5, 2);
					 $dob_day = substr($s_dob, 8, 2);

 

And lines 15, 16 and 17 become:

						 echo tep_draw_pull_down_menu('dob_day', $dob_day_arr, $dob_day);
					 echo tep_draw_pull_down_menu('dob_month', $dob_month_arr, $dob_month);
					 echo tep_draw_pull_down_menu('dob_year', $dob_year_arr, $dob_year);

 

...that's it :). The values from the day of birth will be displayed in the combo-boxes. Hope it helped anyone.

 

Best regards

Share this post


Link to post
Share on other sites

I do not see the need to collect data about our customers date of birth.

 

If I was running an adult site, then maybe (but I would want a more secure method of doing it).

 

With the increase in the numbers of cases of identity theft, I have tried to reduce what I collect to what is required for me to do business with them.


The Coopco Underwear Shop

 

If you live to be 100 years of age, that means you have lived for 36,525 days. Don't waste another, there aren't many left.

Share this post


Link to post
Share on other sites

when Refreshing the site the dob will get reseted, this is a quite big problem as the costumer probably wont see it and that will result in his dob being 01/01/1930.

 

Does anyone know how to make it stay there as the rest of the info?

Share this post


Link to post
Share on other sites

hey I've just installed the contribution and wonder how can I get rid of this "(eg. 29/09/87)" in create account page?

Share this post


Link to post
Share on other sites

I have a small issue while trying to select a day of the month above 12 it consistently says :

 

Invalid Date of Birth (eg. 21/05/1970)

 

no matter what i use above 12, anything 12 or below works fine? Any idea folks :) Thanks!


-------------------------------------------------

Best Regards,

 

ggbig (maestro)

Share this post


Link to post
Share on other sites

Dennis im certainly not an expert but you may be able to look into the file and see how the $HTTP_POST_VARS is set for other stuff in the file and do something similar for the DOB and also i'll see if i can get the specific on a turnery (spelling) operator switch for you to help also :)


-------------------------------------------------

Best Regards,

 

ggbig (maestro)

Share this post


Link to post
Share on other sites
I have a small issue while trying to select a day of the month above 12 it consistently says :

 

Invalid Date of Birth (eg. 21/05/1970)

 

no matter what i use above 12, anything 12 or below works fine? Any idea folks :) Thanks!

 

 

Hello,

 

I was also having the same issue. But its solved I have removed the condition of language checking in create account.php

 

 

if($language == 'english')

{

$HTTP_POST_VARS['dob'] = $HTTP_POST_VARS['dob_month'].'/'.$HTTP_POST_VARS['dob_day'].'/'.$HTTP_POST_VARS['dob_year'];

}

$HTTP_POST_VARS['dob'] = $HTTP_POST_VARS['dob_day'].'/'.$HTTP_POST_VARS['dob_month'].'/'.$HTTP_POST_VARS['dob_year'];

 

replaced this code with

 

if(isset($HTTP_POST_VARS['dob_day']) && isset($HTTP_POST_VARS['dob_month']) && isset($HTTP_POST_VARS['dob_year']))

{

$HTTP_POST_VARS['dob'] = $HTTP_POST_VARS['dob_month'].'/'.$HTTP_POST_VARS['dob_day'].'/'.$HTTP_POST_VARS['dob_year'];

}

 

this one.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×