Community discussions

MikroTik App
 
marrold
Member
Member
Topic Author
Posts: 427
Joined: Wed Sep 04, 2013 10:45 am

Signup page - Use Email Address as Username

Wed Jun 11, 2014 6:56 pm

Hi all,

I'm setting up a signup page to create users for the Mikrotik hotspot service. I have adjusted the HTML in order to remove the profile and payment options, as the profile is always the same, free. I would also like to combine the username and email fields so the user only has to enter the email address to signup, however this doesn't seem to be passing the variable to the usermanager.

html code

<td align="right">
                      email
                    </td>

                    <td align="left">
                      <input type="text" id="sf_email" name="email" 
                             class="signup" value="$(email)" maxlength="100"
                             autocorrect="off" autocapitalize="off">
                    </td>
                  </tr>

<input type="hidden"  id="sf_user" name="login" value="$(email)" class="signup">
What is it I'm doing wrong? I would like to pass the variable from the 'email' box to the username when signing up.

Any help would be much appreciated
 
marrold
Member
Member
Topic Author
Posts: 427
Joined: Wed Sep 04, 2013 10:45 am

Re: Signup page - Use Email Address as Username

Tue Jun 17, 2014 10:11 pm

Ok, so I've been told you can't pass a variable to a hidden input, without using something like Javascript I believe, which is a step in the right direction.
 
marrold
Member
Member
Topic Author
Posts: 427
Joined: Wed Sep 04, 2013 10:45 am

Re: Signup page - Use Email Address as Username

Mon Jun 23, 2014 12:16 am

I found some simple Java script did the job. The following line copies the email value to the login value -
document.signup.login.value = document.signup.email.value;
Ideally, after signup I would like the user to automatically be logged in. Is this possible?

Here is a copy of my signup page. It only asks for an email address, the password and profile are forced, and the username is copied from the email address.

html code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <link rel="stylesheet" type="text/css" href="/umfiles/style.css" media="screen"/>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />  
  <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;"/>
  <title>User Signup</title>
</head>

<script type="text/javascript" src="/umfiles/general.js"></script>

<body>

<form name="signup" action="" method="post"
    onsubmit="return checkSignupForm()">
  <input type="hidden" name="signup" value="start" />

<div id="cntr_container">  
<table id="cntr_conttable">
    <tr>
      <td id="cntr_conttd">
        <div id="cntr_continner">
          <div class="shadow">
            <div class="shadow-inner">
              <div class="shadow-cnt">
                <div id="cntr_logo">
                  <img src="/umfiles/logo.gif" alt="Mikrotik" />

                  <p id="logo_title">RouterOS User Manager</p>
                </div>
                
                <table class="cntr_tbl">
                  <tr>
                    <td align="right">
                      email
                    </td>

                    <td align="left">
                      <input type="text" id="sf_email" name="email" 
                             class="signup" value="$(email)" maxlength="100"
                             autocorrect="off" autocapitalize="off">
                    </td>
                  </tr>
                      
                  <input type="hidden" name="password" value="password">
                  <input type="hidden" name="buy_profile" value="1">
                  <input type="hidden" name="login">
                 
                   <tr>                
                    <td colspan="2" align="right">
                      <input type="submit" name="btn_signup" id="btn_signup" value="Sign up">
                    </td>
                  </tr>

                  <tr>                
                    <td colspan="2" align="center">
                      <p class="signuperror">$(error)</p>
                    </td>
                  </tr>
                </table>          
              </div>
            </div>
          </div>
        </div>


      </td>
    </tr>
  </table>
</div>
</form>

<script language="JavaScript">

  if (document.signup && document.signup.user) document.signup.user.focus();

  function checkSignupForm() {
    if (!checkEmail("sf_email")) return false;
    document.signup.login.value = document.signup.email.value;
    return true;
  } 
</script>

</body>
</html>
thanks
 
abbio90
Member Candidate
Member Candidate
Posts: 207
Joined: Fri Aug 27, 2021 9:16 pm
Contact:

Re: Signup page - Use Email Address as Username

Mon Apr 08, 2024 5:47 pm

Hi, were you able to self-login with email?

Who is online

Users browsing this forum: Google [Bot] and 25 guests