To accomplish a remote login, we're simply passing login credentials off to cPanel / WHM. Security Warning: Use SSL on your login page. You definitely don't want to send your customers' login information out on the net in plain text.
To send these login credentials, we're going to use a form with a POST request. Normally we use the form like this:
However, that only works if we're sending customers to one place, http://mybrandedhost.com:2083/login/. Since we want our customers to be able to go to their webmail (:2096), cPanel (:2083) or WHM (:2087), we'll have to be a bit more crafty. To accomplish this, we introduce some JavaScript and an HTML select:
Now, we're pulling the value of the select named port with:
Then we're changing the action (target) of the form with:
To make sure that this works for all customers on all servers, we'll put them on the right server with this line:
The rest of the JavaScript used is simply to warn the users when they haven't entered a value and to make the form fail in that case. so when we put everything together, we get this JavaScript:
Now, there are a few important things to note about our HTML. Primarily, make sure that you have a space to show your users errors when the form check fails:
Make sure that your form is named loginform as that's what we reference above in the JavaScript. Also, since we've created the form's action in the above JavaScript, all we need to do is use onSubmit to call that JavaScript when the form is submitted:
Other than that, the rest of the form is a few inputs so just make sure you copy the names from the code below. Putting everything together on the HTML side gives us this code:
Now that you understand the code, go ahead and build it into your site's look to get a working login form for your customers.