cPanel, WHM, Webmail login script
By: Daniel

The following code will allow you to login to several different ports that are used for cPanel.

<form action="cpanelLogin.php" method="POST">
<?php
// Show an error if the login failed
if(($_GET['failed'] == "1") or ($error == 1)){
echo '<font color="#FF0000">Your login attempt failed!</font><br />';
}
?>
Domain: <input type="text" name="domain" value="" size="20" /><br />
Username: <input type="text" name="username" value="" size="20" /><br />
Password: <input type="password" name="pass" value="" size="20" /><br />
<?php
// This failurl allows cPanel to redirect back to this site
echo '<input type="hidden" name="failurl" value="http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?failed=1">';
?>
Options: <select name="port">
  <option value="2082">cPanel </option>
  <option value="2083">Secure cPanel </option>
  <option value="2086">WHM</option>
  <option value="2087">Secure WHM</option>
  <option value="2095">Webmail</option>
  <option value="2096">Secure Webmail</option>
</select><br />
<input type="submit" value="Login" />
</form>

Above we created a very basic form to allow the users to login with. You can spice this up to match your site, you just have to make sure that the field names – the name=” some text ” – remains the same.

If you only want to allow cPanel logins you can change the <select name=”port”> to <input type=”hidden” name=”port” value=”2082″>. This allows you to only show the domain, username and password fields.

One thing you will have to make sure you change is the action on the <form> so that it points to the file you will be saving on the next page of this article.

On the next page is the processing of the code.

Pages: 1 2

1 Star2 Stars3 Stars4 Stars5 Stars (19 votes, average: 4.68 out of 5)
Loading ... Loading ...

40 Responses to “cPanel, WHM, Webmail login script”

  1. harris david Says:

    i want cPanel, WHM, Webmail login account.

  2. Richard Matovu Says:

    Hi, thanks so much for sharing this out. I’ve looked for this for quite a lot of time but I am glad to have found a solution here. Please keep it up. However, I would like to know if there is a way I could skip the cPanel Management so that I go directly to Squirrelmail. On my host, I only have one email application squirelmail but still I have to go through cPanel Management

  3. Alex Says:

    Cant understand what changes i have to do in “the brains of this script” and where to put it?

  4. Peter Says:

    Very useful thank you!

  5. Flávio Costa Says:

    Excelent! :)

  6. Kai Says:

    Okay thanks for this.
    ^_^

  7. Vikash Sharma Says:

    Hi I really apreciate this kind of work but it was hard to find it on google I would spread the link of this website so as to appreciate the work
    KEEP GOING

  8. Wahoo Says:

    Thank you for sharing!

  9. Bass Says:

    Thank you, keep it up.

  10. dash Says:

    plese give me script for cpanelLogin.php

  11. Daniel Says:

    Dash, the cpanelLogin.php is on page 2 of this article: http://www.wlscripting.com/tutorial/33/2/

  12. firewind Says:

    Thank you for sharing!
    dash see : http://www.wlscripting.com/tutorial/33/2/

  13. John Says:

    // This failurl allows cPanel to redirect back to this site
    this not work. if all field is complete and the pass or user is wrong then show cpanel login page.

  14. Hrishikesh Says:

    I have tried this script but unable to login.
    Where to add ip address in this script.

  15. bazish Says:

    Thanks for the most wanted script.
    i followed all the instructions, but i got stuck when i input all required information correctly. the error is page can not be displayed.

    i saved the cpanelLogin.php file on server in the same directory from where my page refering this to post. but the same error.
    Yes my server is php enabled. all other php scripts working which are provided here at your site.(the ones that i checked).
    hope to get solution soon as i needed this script.
    thanks

  16. Billy Says:

    If I have customers on more than 1 server, then how would I best integrate the webmail login form? I mean, how does the script know which server to interact with to log the customer into there webmail?

    If anyone has experienced this issue, could you please share?

    Thanks.

    Magik

  17. Daniel Says:

    This automatically determines which server to login to due to the user putting in their own domain name in the form. Since DNS knows which server that domain name is on it routes the requests to that server.

  18. aguy Says:

    This cant be secure – it SHOWS the password in the url b4 it logs in. surely thats not good?

  19. Ivan Says:

    I copied and paste the code as it was to the server but the following message appears:
    Cannot modify header information – headers already sent by (output started at /home/.obelixdryer/arshaorg/arsha.org/new/globals.php:44) in /home/

    I found several articles that states that it’s caused by an extra space but I didn’t find any. Could it be something else or what am I missing?

  20. Daniel Says:

    Ivan,

    Check that you don’t have any spaces at the end of any lines in the code. This also includes all files that are included in your page.

  21. Customizing Webmail/cPanel/WHM Login Page | Arvixe Blog Says:

    [...] Update on December 29th, 2008: MartinH on our forums at http://forum.arvixe.com/smf/general/customizing-webmail-interface/ mentioned that while the above script works, there is a notification your visitors will receive using the Opera browser. The following form found at http://www.wlscripting.com/tutorial/33 provides an alternate form that does not give the initial warning in Opera. Also, the form is not using PHP so it can be deployed on servers without the PHP engine (all accounts at Arvixe do have the PHP engine): [...]

  22. Mike Says:

    Hi
    Am trying to get it to work, but like Ivan I am having trouble.

    I receive this: Warning: Cannot modify header information – headers already sent by (output started at /home/cklwebco/public_html/cpanelLogin.php:9) in /home/cklwebco/public_html/cpanelLogin.php on line 32.
    I have looked for spaces on that line, but after trying everything it still won’t function.
    You said to Ivan to find spaces in all files on the page, but are you referring to only the cpanelLogin.php page where teh error is occurring or the page where I am placing the Login?
    Cheers for a great script.
    Mike

  23. Mike Says:

    All good Daniel. Please ignore earlier post.
    Cheers
    Mike

  24. ashutosh shukla Says:

    Hey Daniel,
    I tried to get re-directed to the webmail of cpanel in some what differene manner then this one. This pattern makes the users visit the cpanel. which, then gets auto re-directed ,as I set the Horde as the redirector for them.
    I would like to know if there is a way I could skip the cPanel Management so that I go directly to Horde or Squirrelmail.

  25. Volkan AGAOGLU Says:

    Thank you so much very usefull

  26. Muqeem Says:

    Wao Great Mr. Daniel !
    This script realy too much help me.

    Good Very Good

    Keep continuing post latest script but with little help.

  27. Geline Says:

    Not working for me

  28. surya Says:

    not working loginscript please help me sir

  29. dianne Says:

    i can’t sign in to my email at webmail can you help.

  30. GG Says:

    Hello,

    I can successfully login to my WHM and cPanel but canot login to webmail:2095.
    I get a login attempt failed and yes i have double checked my username and password.

  31. Leonardo Says:

    hello when index.html and upload the php file and attempted to enter the login I get this error

    Your login attempt failed!
    ‘; } ?> Domain:
    Username:
    Password:
    ‘; ?> Options:

    please check the page
    http://www.webhostlm.com/sp/cpanel

  32. pagerank tool Says:

    nice script , i am searching this for all valid ports

  33. akimie Says:

    notworking with me too ..same problem with pagerank tool ..

  34. John Matt Says:

    Hey… very nice script. Works for me. But got just 1 Q. When i login, my password is displayed in the address bar on the next webmail login page. Any suggestion how can i encrypt this password.

  35. John Matt Says:

    When I try secure webmail…It says Certificate Error…..

  36. vasudev Says:

    Thx Daniel ,
    good job .

    This script realy too much help me.

    but sir i have one question ?
    can we login in webmail without showing the domain name text box and option button . if yes please send me the code on the email id . i will be more thankful

    Thanks & Regards
    Vasudev

  37. ali Says:

    its not redirecting to the sam page if login fails ?

  38. Shiv Says:

    Thnx Daniel,
    Very usefull script. But i m little bit worried about user name and password which is showing in address bar. It can be serious issue if a user is working on a public computer. Any solution will be appreciated.

    Thanks & regards,
    Shiv

  39. cPanel Host Says:

    Fantastic web log. Added to Facebook!

  40. php techie Says:

    Hi Daniel..,
    Its a nice article and easy to capture of the concept.. Its a great job to you:-)
    Thanks a lot..!

Leave a Reply

geovisitors