Mandatory user fields Mandatory user fields
 

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]

Main Menu

Mandatory user fields

Started by Hein Traag, December 07, 2004, 11:59:27 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Hein Traag

If mandatory means "must be filled in" then i've chosen the right word.

Have searched the board but with no satisfying result :(

Is is possible to alter the registration proces of new users so that they have to fill in certain fields.
And if they do not that the registration can not take place.

Or someone tells me i should upgrade my search skills  ;D and points me in the right direction. For which i thank you in advance  ;)

Nibbler

Just add a line into register.php:

under
$occupation = addslashes(get_post_var('occupation'));

add
if (!$occupation) $error .= "<li>You must fill in your occupation!";

Joachim Müller

You could as well spice this up with some JavaScript to prompt the user to fill in the mandatory fields even before (when he tries to submit the form). Edit register.php, find    starttable(-1, $lang_register_php['enter_info'], 2);
    echo <<<EOT
        <form method="post" action="$PHP_SELF">
and replace with    starttable(-1, $lang_register_php['enter_info'], 2);
    echo <<<EOT
<script type="text/javascript">
<!--
    function chkForm()
    {
     if(document.myform.user_profile1.value == "")
      {
       alert("Please fill in FOOBAR");
       document.myform.user_profile1.focus();
       return false;
      }

     if(document.myform.user_profile2.value == "")
      {
       alert("Some other alert text to tell the user he is behaving naughty!");
       document.myform.user_profile2.focus();
       return false;
      }
}
-->
</script>
        <form method="post" action="$PHP_SELF" name="myform" onsubmit="return chkForm();">
(From the back of my head, not tested though).
Users who disabled JavaScript will not see the prompt - to make this foolproof, you'll have to check as suggested by Nibbler anyway.

Joachim

Hein Traag

Thanks for the tips. Will try at home.

Going to use this on a gallery which requires users to register with their scouting membership number.

I assume there is also a way to have a javascript check on what sort of input has been given into
a field ? For example if all characters are numbers and also check the amount of numbers.

Casper

It has been a long time now since I did my little bit here, and have done no coding or any other such stuff since. I'm back to being a noob here

Hein Traag

Thanks Casper ;)

*makes mental note profile fields = user fields

But thanks for the information so far!