Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

dob dropdown


Guest

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?

Link to comment
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

Link to comment
Share on other sites

  • 3 months later...

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.

Link to comment
Share on other sites

  • 4 months later...

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.

Link to comment
Share on other sites

  • 2 months later...
  • 4 weeks later...

@ 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.

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...
  • 1 month later...
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

Link to comment
Share on other sites

  • 5 months later...

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

Link to comment
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.

Link to comment
Share on other sites

  • 9 months later...

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?

Link to comment
Share on other sites

  • 5 weeks later...
  • 11 months later...
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.

Link to comment
Share on other sites

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...