How Do I Create A Custom Cpanel Login Form

How do I create a custom cPanel login form?

So, have you ever wanted create your own custom cPanel or Webmail login form? We sure have, and since cPanel shares the same login interface for both Webmail and cPanel, we can easily use some clever PHP paired with a customizable HTML form to get the job done.

Why Create A Custom cPanel & Webmail Login Form?

Face it, cPanel loves their branding — and they should because it’s pretty darn slick, however they offer very little in the way if carrying over your own branding and the login interface is no exception.

Whether creating a custom cPanel/Webmail login form is for your own access or perhaps you are a hosting provider or reseller and want to give your customers custom access to their control panel — we are going to walk you through a simple way to shield the standard login interface that is seen when typing in (YOURDOMAIN.com/CPANEL) or (YOURDOMAIN.com/WEBMAIL) and replace it with your own customizable login form that will work for both cPanel and Webmail access.

Step 1 — The HTML Login Form

Alright, in order to keep things simple, we are going to be straight forward with our form markup and leave the styling out of this tutorial.

After all, you will probably want to customize the way your form looks to match your website anyway. The form code below contains our username, password, and radio selections for either cPanel or Webmail. When referencing the code, make sure you keep the input names (ie: name=”XXXX”) in tact as these will be utilized in our next step involving the PHP code that will be used to process the form.

<form action="login.php" method="post">
<input name="User" type="text" placeholder="Username or E-mail" required />
<input name="Pass" type="password" placeholder="Your Password" required />
<input name="port" type="radio" value="2083">
<strong>cPanel</strong>
<input name="port" type="radio" value="2096">
<strong>Webmail</strong>
<input type="submit" value="Login" />

Step 2 — The PHP Code To Process The Form

This PHP code will be the processor that takes the user to either cPanel or Webmail.

In short, what this code does is construct a URL string and passes the required credentials that are used by cPanel to complete the login process behind the scenes. Based on the above HTML form code, you can see that the form action calls for login.php — here is the PHP code to create the login.php file, you will simply need to supply your domain or IP address for $domain=”XXX”.

<html>
<?php
#your domain or ip
$domain = "XXX";
if(!$_POST['login']) {
exit;
}
$user = $_POST['User'];
$pass = $_POST['Pass'];
$port = $_POST['port'];
$port == "2083" || $port == "2096" ? $pre = "https://" : $pre = "http://";
?>
<body onLoad="setTimeout('document.forms[0].submit();',10)">
<form action="<?php echo "".$pre."".$domain.":".$port."/login/"; ?>" method="post">
<input type="hidden" name="user" value="<?php echo $user; ?>">
<input type="hidden" name="pass" value="<?php echo $pass; ?>">
</form>
</body>
</html>

That’s all there is to it!

Now, you will want to upload your form file and your PHP processor file and give it a test. If all checks out, you can customize your HTML form to be integrated into your website for custom access to cPanel and Webmail.

Leave A Comment

Vessio

Need some help?

Share a few details about your new or existing website.


    Text Us 24/7