Hi Raymond,
 
  It is one file.  I have recreted my VERY stripped down example from my 
original post with a few more details that may or may not clear up what I am 
doing. When the page loads for the first time the <%init> section is processed 
first and I check the the value of $Submit, the name I gave to my submit 
button.  
 
    Since the page is loading for the first time and hence Submit has not been 
clicked then $Submit is False (0) and the code in the if($Submit) blocks is not 
executed.
 
   If someone then clicks on Submit it POSTs the form back to the server. The 
<init> is run again and this time $Submit is True so it executes the code in 
the block which processes the values in the fields. If I detect a problem with 
the form data (like a blank Email_Address) then I break out to the END: so that 
the page will redisplay with my message (In my real page I have seperate errors 
for each field).
 
  The user could then correct their error and resubmit the page by clicking the 
Submit button again.
 
 If the page runs through all the checks OK then I either stay on this page and 
the user can navigate away with other buttons (not shown) or I use an 
$m->redirect to send them to the next step of whatever process I want them to 
perform. 
 
 
 
<html><body><form method="POST">
<% $Message %><input type="text" name="Email_Address" size="25" maxlength="30" 
value="<% $Email_Address %>"><input type="password" name="Password" size="25" 
maxlength="30"><input type="password" name="Confirm_Password" size="25" 
maxlength="30"><input type="submit" name="Submit" value="Create 
Account"></form></body></html> 
<%args>
    Email_Address
    Password
    Confirm_Password
    Submit => 0
</%args>
<%init>  
    my $Message;    if($Submit)    {        if($Email_Address eq '')        {   
         $Message = "You must enter your Email Address";            goto END;   
     }              if($Password ne $Confirm_Password)        {            
$Message = "The Passwords do not match. Please enter them again";            
$Password = "";            $Confirm_Password = "";            goto END;        
}                my $Success = 
AccountManagement::Create_Account($Email_Address, $Password, 1);       
 
        $Message = "Account created successfuly" if $Success;
 
        #I also could have put an $m->redirect here to automatically go onto to 
the next page if desired.    }     END:</%init>
_________________________________________________________________
When your life is on the go—take your life with you.
http://clk.atdmt.com/MRT/go/115298558/direct/01/
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to