[ic] form profile help

Matt Johnston interchange-users@icdevgroup.org
Sat Nov 23 19:04:01 2002


I have read through the mailing list and I have successfully altered the 
New Account and Login pages to accept an email as the username.  Basically 
I am leaving the unique user id alone, I am just requiring a unique email 
address.  My problem is when I try to have the user change their email 
address.  I have to run a check to see if the address is unique (I am using 
4.8.6).  I have tried many different methods, but none have worked.

I tried using the email=unique userdb:email, but that basically caused the 
whole form to not work.  I would setup my profile as

email=required
email=email
&fatal=1
email=unique userdb:email

Whenever I tried to submit this form, the form failed but no error messages 
where shown.  If I take out the email=unique line everything works fine, I 
get the error messages.  Any ideas on why the email=unique is bumming up 
everything?

Since this didn't work, I tried using a profile in my profiles.misc 
file.  My form is very simple:
<input type=hidden name=mv_session_id value="[data session id]">
<INPUT TYPE=hidden NAME=mv_doit  VALUE=return>
<input type=hidden name=mv_check value=change_email>
<INPUT TYPE=hidden NAME=mv_nextpage VALUE=change_email>
<input type="text" name="email">

And my profile looks like:

__NAME__ change_email
        [tmp email_used][strip]
         [query sql="select email from userdb where email ='[cgi email]' 
and username<>'[value mv_username]'" type=row_count]
                 [sql-row_count]
         [/query]
      [/strip][/tmp]

[if type=value term=[cgi email] op="!~" 
compare="/\w+@[-A-Za-z0-9.]+\.[A-Za-z]+/"]
[set form_errors]Please enter a valid email address[/set]
[elseif scratch email_used]
         [calc]
                 delete $CGI->{email};
                 delete $::Values->{email};
         [/calc]
          [set form_errors]Email address already in our system[/set]
         [/elsif]
         [else]
         mv_nextpage=account
         [/else]
      [/if]
__END__


The top porition that sets the email_used variable works.  That is the same 
code I use when I create a new account.  My problem comes when I try to 
check [cgi email] against the email regex.  For some reason I can never get 
this check to work.  I have tried rewriting the if statements ten different 
ways, and it just seems like the if statement is not getting the value of 
[cgi email].  Am I missing something simple about the way forms will use 
profiles?

Matt Johnston

http://www.lattaoutdoors.com
http://www.thebackpacker.com