Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Required Fields Specific  (Read 6036 times)

0 Members and 1 Guest are viewing this topic.

travelbuff

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Required Fields Specific
« on: January 20, 2013, 05:49:39 am »

I'm using the required fields for registration code. previously listed in the forum that works great.  Is there anyway to make them more specific for validation?  For example a zip code field, to take only numerals?  I'm having problems with spammers registering with just jibberish in my required fields and I would like to make it just a little harder for them to spam me.  I have the captcha on also.

Any idea's?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Required Fields Specific
« Reply #1 on: January 21, 2013, 12:36:11 pm »

Please post a link to the mod/plugin you use.
Logged

travelbuff

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: Required Fields Specific
« Reply #2 on: January 21, 2013, 02:27:08 pm »

Andre

I'm not using a plugin, just the coding that was supplied in the forum to make the fields mandatory.  I want to validate the fields also.  Is there a plugin for field validation, I did not see one?
Logged

phill104

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4885
    • Windsurf.me
Re: Required Fields Specific
« Reply #3 on: January 21, 2013, 02:40:16 pm »

Please post a link to where you got the code from. There are so many mods out there we just cannot know exactly which you are using.
Logged
It is a mistake to think you can solve any major problems just with potatoes.

travelbuff

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: Required Fields Specific
« Reply #4 on: January 21, 2013, 02:50:51 pm »

Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Required Fields Specific
« Reply #5 on: January 21, 2013, 03:10:27 pm »

That mod was designed for cpg1.4.x. It won't work for cpg1.5.x because the superglobal $_POST doesn't exist. I assume you're still running cpg1.4.x (which is unsupported for over two years now)? However, a simple preg_match should do the trick.
Logged

travelbuff

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: Required Fields Specific
« Reply #6 on: January 21, 2013, 03:18:50 pm »

Andre

Yes I was a little behind.  I should state it did work.  I actually did the latest upgrade yesterday.  Could you explain the simple preg_match and how that would fit into the code?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Required Fields Specific
« Reply #7 on: January 21, 2013, 03:23:27 pm »

Sorry, I looked at the wrong code line. Actually, the lines you have to find look different in cpg1.5.x, so the mod still works if you find the correct lines:
Code: [Select]
    $profile1 = $superCage->post->getEscaped('user_profile1');
    $profile2 = $superCage->post->getEscaped('user_profile2');
    $profile3 = $superCage->post->getEscaped('user_profile3');
    $profile4 = $superCage->post->getEscaped('user_profile4');
    $profile5 = $superCage->post->getEscaped('user_profile5');
    $profile6 = $superCage->post->getEscaped('user_profile6');


Could you explain the simple preg_match and how that would fit into the code?
That's currently not possible as I don't know which data validates each field. Additionally, please post the modified code block.
Logged

travelbuff

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: Required Fields Specific
« Reply #8 on: January 21, 2013, 04:00:07 pm »

Ok here is what I have now;
Code: [Select]
    $user_name = trim(get_post_var('username'));
    $password = trim(get_post_var('password'));
    $password_again = trim(get_post_var('password_verification'));
    $email = trim(get_post_var('email'));
    $profile1 = $superCage->post->getEscaped('user_profile1');
    if (!$profile1) $error .= "<li>it's mandatory to fill in your City and State";
    $profile2 = $superCage->post->getEscaped('user_profile2');
    if (!$profile2) $error .= "<li>it's mandatory to fill in your Gender";
    $profile3 = $superCage->post->getEscaped('user_profile3');
    if (!$profile3) $error .= "<li>it's mandatory answer Yes or No";
    $profile4 = $superCage->post->getEscaped('user_profile4');
    if (!$profile4) $error .= "<li>it's mandatory to enter your birth year";
    $profile5 = $superCage->post->getEscaped('user_profile5');
    if (!$profile5) $error .= "<li>it's mandatory answer Yes or No";
    $profile6 = $superCage->post->getEscaped('user_profile6');
    $agree_disclaimer = $superCage->post->getEscaped('agree');
    $captcha_confirmation = $superCage->post->getEscaped('confirmCode');
I would like to make the birth year validate 4 digits and to validate the yes or no answers to be "yes or no".
Logged

travelbuff

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: Required Fields Specific
« Reply #9 on: January 21, 2013, 11:10:18 pm »

Would something like this work.  I'm not much on php coding?  Any help would be greatly appreciated.  ;)

Code: [Select]
$profile2 = $superCage->post->getEscaped('user_profile2');
    if ((!$profile2)(!in_array(strtolower(trim($_POST['gender'])),array('male','female','couple')) $error .= "<li>It's mandatory to fill in your Gender";
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Required Fields Specific
« Reply #10 on: January 22, 2013, 09:17:36 am »

Gender and yes/no:
Code: [Select]
if (!in_array(strtolower(trim($profile2)), array('male','female','couple'))) $error .= "<li>It's mandatory to fill in your Gender";
Year of birth:
Code: [Select]
if (!preg_match('/[0-9]{4}/', $profile4)) $error .= "<li>it's mandatory to enter your birth year";
Logged
Pages: [1]   Go Up
 

Page created in 0.02 seconds with 20 queries.