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.


Posted

in

by


  • The Power of Rate Limiting: Enhancing Website Traffic and Performance

    In the fast-paced digital landscape, where website traffic and user interactions are at an all-time high, ensuring optimal performance and security has become a critical concern for website administrators. One effective technique that can significantly improve both website traffic management and performance is rate limiting. Rate limiting is a method that controls the number of…

  • How do I Remove the “Save my name” Checkbox In WordPress?

    In WordPress, when users leave comments on your blog posts, they are often asked to provide their name, email address, and website. By default, WordPress includes a checkbox labeled “Save my name, email, and website in this browser for the next time I comment.” This checkbox allows users to have their information saved in cookies,…

  • How do you force SSL and fix mixed content with HTACCESS?

    So, you have a shiny new SSL certificate for your website, and now you need to force SSL, but you keep getting mixed content errors. This simple guide will consist of two parts and should get you up and running with a “green lock” in no time. Step 1 — You Need To Modify Your…

  • How do I reset all form fields using pure JavaScript?

    It doesn’t matter why you might want to add a reset form button for your users. It could be that the form has conditional logic, is super long, complex, or that it has form fields that are prone to user error. We will look at a straightforward way to add a form button to reset…

  • How do I create a simple news ticker using HTML and CSS?

    Alright, so you need some text, links, or images to scroll across your website from left to right. Some folks call this a “news ticker”, some call it a “text scroller” — we will stick with news ticker for the sake of keeping our references simple. Sure, you can make this happen with JavaScript but why complicate…

  • How do I make a textarea form field match an input form field?

    Have you ever wondered why the default font for a form textarea field is different when using a placeholder? The default fonts for all web forms are usually determined by the browser used, and technically, it is up to us to define what fonts or styles to display via our CSS. Here is how you…