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?
Please post a link to the mod/plugin you use.
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?
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.
Sorry,
I'm using this bit of code; http://forum.coppermine-gallery.net/index.php/topic,33757.0.html (http://forum.coppermine-gallery.net/index.php/topic,33757.0.html).
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.
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?
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:
$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');
Quote from: travelbuff on January 21, 2013, 03:18:50 PM
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.
Ok here is what I have now;
$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".
Would something like this work. I'm not much on php coding? Any help would be greatly appreciated. ;)
$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";
Gender and yes/no:
if (!in_array(strtolower(trim($profile2)), array('male','female','couple'))) $error .= "<li>It's mandatory to fill in your Gender";
Year of birth:
if (!preg_match('/[0-9]{4}/', $profile4)) $error .= "<li>it's mandatory to enter your birth year";