www.webdeveloper.com
Results 1 to 2 of 2

Thread: [RESOLVED] I built a registration class and i need help wiring up the front end (api layer)

Threaded View

  1. #1
    Join Date
    Jun 2011
    Location
    California
    Posts
    383

    resolved [RESOLVED] I built a registration class and i need help wiring up the front end (api layer)

    Using oracle server 11g.

    My front end is only 4 input boxes. I have some javascript validation as well but it's working fine so i won't post it, mainly having problems with how my classes interact with the form elements.

    HTML Code:
                <form id='register' action='register.php' onsubmit="return validateForm()" method='post' accept-charset='UTF-8'>
    <fieldset>
    <legend><br/>Create An Account</legend><br/>
    <input type='hidden' name='submitted' id='submitted' value='1'/>
    <label for='username' >Username*: </label>
    <input type='text' name='username' id='username' maxlength="50" /><br/><br/>
    <label for='email' >Email Address*:</label>
    <input type='text' name='email' id='email' maxlength="50" /><br/><br/>
    <label for="password">Password*:</label>  
    <input type="password" name="password" placeholder="password" required><br/><br/>
    <label for="password">Confirm Password*:</label>  
    <input type="password" name="password" placeholder="password" required><br/><br/>
    <label for='cpassword' >&zwnj;</label>
    <input type="hidden" name="fsubmitted" value="TRUE"><input type='submit' name='Submit' value='Register' />
    </fieldset>
    </form>
    PHP Code:

    public function create($password) {
            global 
    $db;

            if (!
    $this->get_email() || !$this->get_username()) {
                return 
    false;
            }

            
    $vars = array();
            
    $vars[] = array(':email'$this->get_email());
            
    $vars[] = array(':username'$this->get_username());
            
    $vars[] = array(':password'$password);

            
    $id $db->get_function_as_proc('custom.japi_shopper_identity.create_user(:email, :username,  :password)'$vars);
            
    $this->set_id($id);

            
    // If it failed, it'll puke on the procedure. If we've come this far, we
            // know it worked.
            
    return true;
        }

    public function 
    request_activation() {
            global 
    $db;

            
    $vars = array();
            
    $vars[] = array(':i_shopper_id'$this->get_id());

            
    // Returns a temp token
            
    $temp_token $db->get_function_as_proc('custom.japi_shopper_identity.activate_user_request(:i_shopper_id)'$vars);

            if (
    $temp_token == null) {
                return 
    false;
            } else {
                
    $this->send_activation_email();
                return 
    $temp_token;
            }
        }

    public function 
    set_email($email) {
            return 
    $this->email $email;
        }

     public function 
    set_username($username) {
            return 
    $this->user_name $username;
        } 
    When I hit the register button what code should i have in action="register.php"?

    Should i be able to keep all my code on one page?

    And just instantiate the class Shopper?

    $shopper = new Shopper();
    $shopper->set_email($new_username.'@example.com');
    $shopper->set_username($new_username);
    $shopper->create('password');
    $token = $shopper->request_activation();

    Also, I should aware of empty strings??

    and than hopefully the request_activation function will send them the e-mail for them to click the activate link?? Any help would be greatly appreciated. Thanks in advance.
    Last edited by Supplement; 11-12-2013 at 12:09 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles