State Field as Dropdown On Signup

Discussion in 'aMember Pro v.4' started by cpaprotna, Feb 11, 2014.

  1. cpaprotna

    cpaprotna Member

    Joined:
    Dec 23, 2013
    Messages:
    44
    How do you get the State field on a signup form to display as a drop down? Right now, it's just a text field. I am using a custom .phtml file to layout my signup forms. The html returned by the form object just has it as a text box. When I configure the fields on the form, I have the country not displaying and set to United States. When I view the source, there is the following:
    Code:
    <select name="state" id="f_state" disabled="disabled" style="display: none">
    </select><input type="text" name="state" id="t_state" /></div>
  2. scottlott

    scottlott Member

    Joined:
    Jun 17, 2010
    Messages:
    50
    It might be easier to setup a signup form on your own HTML page and send the new signup information to aMember through the Rest API.

    I did it on my website on this page. It's very easy if you know a little PHP and HTML.
  3. cpaprotna

    cpaprotna Member

    Joined:
    Dec 23, 2013
    Messages:
    44
    After you collect the data from the signup form and add the user can you then send to page to amember's checkout page for payment? I'm fairly good with php and html, just haven't used their API very much yet. Is there anyplace that has some good sample code? This may solve some of my other issues as I have a pretty complex signup form that needs to register multiple users with a few products each.
  4. scottlott

    scottlott Member

    Joined:
    Jun 17, 2010
    Messages:
    50
    This is what I'm using, I use the HTML5 signup form method "POST" to this page, and the rest is done here:

    I also send the registration Email from here, since aMember doesn't send registration Emails for people signed up through the API.

    Code:
        <center>
        <div id="error" style="display:none;">Oops, something isn't working right.  Here's the error:<br/>
            <div id="aMemberResponse">
            <?php
     
            $url = 'http://website.com/amember/api/users';
     
            $fields = array(
                '_key' => 'aMemberAPIkey',
                '_method' => POST
                );
     
            $fields['pass'] = $_POST["pass"];
            $fields['email'] = $_POST["email"];
            $fields['login'] = $_POST["username"];
     
            $fields_string = http_build_query($fields);
     
     
            $ch = curl_init();
     
            curl_setopt($ch,CURLOPT_URL,$url);
            curl_setopt($ch,CURLOPT_POST,count($fields));
            curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
     
            $result = curl_exec($ch);
     
            curl_close($ch);
     
              $name = "Website.com";
            $email = $_POST['email'];
            $from = "rcspowers@gmail.com";
            $to = $_POST["email"];
            $subject = "Website.com Registration";
            $headers = 'From: ' . $name . "\r\n" .
            'Reply-To: ' . $from . "\r\n" .
            'X-Mailer: PHP/' . phpversion();
            $headers  .= 'MIME-Version: 1.0' . "\r\n";
            $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
            $body = "Hello,<br/><br/>Thank you for registering at Website.com!<br/><br/>Login to your account <a href='http://www.website.com/'>here</a> using the details below:<br/><br/>Username: " . $_POST["username"] . "<br/>Password: " . $_POST["pass"] . "<br/><br/>";
     
          if (mail ($to, $subject, $body, $headers)) {
          } else {
                  echo "Error: Problem sending registration email.";
          }
     
     
            ?>
            </div>
        </div>
        <div id="okay" style="display:none;">You've signed up succesfully!<br/>You can login <a style="text-decoration:underline;color:blue;" href="http://www.website.com/community/login">here</a>.</div>
        </center>
        <script>
        window.onload = setTimeout(checkforErrors,1000);
        function checkforErrors() {
            var Message = document.getElementById('aMemberResponse').innerHTML;
            if(Message.search("error") > 0) {
                document.getElementById('error').style.display = "block";
            } else {
                document.getElementById('okay').style.display = "block";
                setTimeout(function() {
                    //Redirect code, ended up not using it.
                    //window.location = "http://www.website.com/";
                },2000);
            }
        }
        </script>
    I'm sure you could easily redirect them to whatever page you want after this, either using a link, meta refresh, or uncomment the window.location code at the bottom.

Share This Page