lukinhasb Posted May 7, 2014 Share Posted May 7, 2014 Hello, I know that for the client to login from outside WHMCS I just have to use <form method="post" action="/dologin.php"> But when it comes to register, what should I do? Maybe this would work? <form method="post" action="/register.php"> 0 Quote Link to comment Share on other sites More sharing options...
lukinhasb Posted May 7, 2014 Author Share Posted May 7, 2014 Plus, how can I make it ask for password only once, instead of asking it twice for verification? 0 Quote Link to comment Share on other sites More sharing options...
lukinhasb Posted May 7, 2014 Author Share Posted May 7, 2014 (edited) Okay so, I'm halfway through. I have managed to duplicated the password field into the pw verification, and also created the whole form externally to be sent via POST to register.php, with same field values of clientregister.tpl, wich also points to register.php The problem is it's not working, when I submit the form I get to the clientarea login page. <form id="formulario-registro" method="post" action="register.php" class="form-stacked" autocomplete="off"> <input type="hidden" name="register" value="true" /> <input type="hidden" name="country" id="country" value="BR" /> <!-- Name --> <div class="campo-registro"> <label for="firstname" class="registro">Full Name</label> <span class="formwrapper-registro"> <input type="text" name="firstname" id="firstname"/><br class="naofrita"> <label class="registro-error" for="firstname" generated="true"></label> </span> </div> [... All the other messy inputs ... ] <input type="submit" value="Submit"> </form> PS: I've hardcoded the country as a hidden input to shorten the number of inputs and make the form shorter and less boring. Already tried using the legit way to select a country and such, without passing a hardcoded value. Same results. Edited May 7, 2014 by lukinhasb 0 Quote Link to comment Share on other sites More sharing options...
lukinhasb Posted May 7, 2014 Author Share Posted May 7, 2014 (edited) Okay, I've managed to advance a lot, the only thing missing now is to generate dynamic tokens for the requests. How can I do this PLEASE?? <input type="hidden" name="token" id="token" value="40 CHARACTERS TOKEN" /> PS: Both the "external" register file and WHMCS are on the same website! WHMCS is a sub-folder, I'm doing this because I want the client to register on a modal on my website PS 2: So, just debugged this token stuff. It's confirmed to be the only thing stopping my script from working I have pointed the original register script at whmcs to test.php, wich outputs all the vars that has been posted Using the token in my script makes it work, but it only works once, after the first use it expires. I want to know the dynamic code to generate this token Thanks! Something like: <form id="external-register" method="post" action="/register.php"> <?php $autoauthkey = "************************"; # autoauthkey from configuration.php, turned them to * for security purposes $timestamp = time(); # Get current timestamp $email = "[Here it should go the e-mail entered in the form, right? I don't know how to do that. Token didn't work with static e-mail neither]"; # Clients Email Address to Login $hash = sha1($email.$timestamp.$autoauthkey); # Generate Hash ?> <input type="hidden" name="token" id="token" value="<?php echo $hash; ?>" /> <input type="hidden" name="register" value="true" /> <input type="text" name="firstname" id="firstname"/> <input type="text" name="lastname" id="lastname"/> <input type="text" name="email" id="email"/> <input type="password" name="password" id="password"/> <input type="password" name="password2" id="password2"/> <input type="text" name="phonenumber" id="phonenumber"/> <input type="text" name="companyname" id="companyname"/> <!-- Hid unnecessary fields because of conversion rate --> <input type="hidden" name="address1" value="" /> <input type="hidden" name="address2" value="" /> <input type="hidden" name="city" value="" /> <input type="hidden" name="state" value="" /> <input type="hidden" name="postcode" value="" /> <input type="hidden" name="country" id="country" value="BR" /> </form> Tried generating a random string of 40 numbers similar to the token, didn't work lol function makeid() { var text = ""; var possible = "abcdefghijklmnopqrstuvwxyz0123456789"; for( var i=0; i < 40; i++ ) text += possible.charAt(Math.floor(Math.random() * possible.length)); return text; } $("#token").val(makeid); Edited May 7, 2014 by lukinhasb 0 Quote Link to comment Share on other sites More sharing options...
lukinhasb Posted May 10, 2014 Author Share Posted May 10, 2014 BUMP Still need to generate that token, can someone help me please? Thanks 0 Quote Link to comment Share on other sites More sharing options...
JamieErrota Posted May 12, 2014 Share Posted May 12, 2014 Hello, Nice idea I wish you the best of luck. Kind regards, Jamie 0 Quote Link to comment Share on other sites More sharing options...
jclarke Posted May 12, 2014 Share Posted May 12, 2014 The current token is stored in $_SESSION["tkval"] What you could try to do is include the init.php file for WHMCS which will give you a valid WHMCS session and then set the $_SESSION["tkval"] to the token that you pass on the registration form. I haven't tested this so I can't guarantee it will work, but it is worth a try! 0 Quote Link to comment Share on other sites More sharing options...
dm800pvr Posted November 5, 2014 Share Posted November 5, 2014 I'm intrested too but token won't allow!! 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted November 5, 2014 Share Posted November 5, 2014 Why don't you just use API:Add_Client? 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.