icon Learn how to get the most out of Surmunity - read our forum tips here! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » Reseller Hosting » How to: cPanel Form on Website.

Reseller Hosting Questions about your reseller hosting account.

Reply
 
LinkBack Thread Tools Search this Thread
Old August 26th, 2006, 9:08 PM   #1 (permalink)
Bow before Surpass!
Super #1
 
Joined in Sep 2004
1,542 posts
Gave thanks: 91
Thanked 49 times
How to: cPanel Form on Website.

*Although this can work for anyone, even those not reselling, this is a cool extra for Reseller's websites to help their customers*

Here is alittle tutorial on how to setup a cPanel login form on your website! NOTE: This code has the option for those logging in to make it is SSL connection or not. IF YOU DO NOT HAVE SSL ACCESS (https://) THEN PLEASE SEE STEP 3!!

----------------------------------------------------------------------------------------

Step 1: Form Code (basic)
Code:
<form action="cpanel.php" method="post">
Username: <input type="text" name="user"><br>
Password: <input type="password" name="pass"><br>
<input name="secure" type="checkbox" value="1" checked /> Secure Login?<br>
<input type="submit" name="submit" value="Login!">
</form>
This code creates a basic HTML form with values that will be used in the "cpanel.php" script. You may modfy this code in anyway, just be sure to keep the following: method="post", name="user", name="pass", name="secure", value="1", and name="submit". These are needed to retreive the right information for the script "cpanel.php" to work.

Step 2: Creating cPanel.php
The following uses PHP commands to transfer the information from the form to generate a cPanel login.
PHP Code:
<?php
// cPanel Login - NOTE: Replace website.com with your own url/domain!
if ($_POST["submit"]) {
if ((!
$_POST["user"]) || (!$_POST["pass"])) {
echo(
"Please complete all fields.");
}
else if (
$_POST["secure"] == 1){
    
header("Location: https://".$_POST["user"].":".$_POST["pass"]."@website.com:2083");} 
else {
    
header("Location: http://".$_POST["user"].":".$_POST["pass"]."@website.com:2082");}
}
?>
The first part asks if the "submit" button was clicked. then it checks to make sure both fields "user" (username) and "pass" (password" have information values, if not display the following error, "Please complete all fields.". However, if all information is found, then it proceeds with checking if the "secure" value equals "1" (aka, if the user has checked that he/she wants a SSL connection). If so, it will login using "https" and port "2083" (the secure cPanel port), if the box was unchecked, it will login using "http" and port "2082" (the unsecure cPanel standard port).

Once you've made your edits, save/close.

Step 3: What to Do if Your Account Doesn't have SSL?
If your account doesn't support SSL (usually shared servers require a one time fee for SSL, dedicated servers get it for free), then you can (and is recommended) remove the following from the form HTML code:
Code:
<br>
<input name="secure" type="checkbox" value="1" checked /> Secure Login?
And remove this from cPanel.php:
PHP Code:
else if ($_POST["secure"] == 1){
    
header("Location: https://".$_POST["user"].":".$_POST["pass"]."@website.com:2083");} 
else {
    
header("Location: http://".$_POST["user"].":".$_POST["pass"]."@website.com:2082");} 
And replace the code with the following:
PHP Code:
else {
header("Location: http://".$_POST["user"].":".$_POST["pass"]."@website.com:2082");} 
And save/close. This will remove the SSL functions fro mthe script, so that it is more efficient. However, as long as the secure field isn't checked, it would still work, this is just my suggested way on making it more clean and actually efficient. I mean, if you don't have SSL, why have the script check?

Step 4: Creating Other Service Logins
You can create logins for cPanel, but why not include this type of love for WHM, Webmail, and Broswer FTP users? You can, and with just two simple changes!

First, the most obvious change is the file name the HTML form uses. In fact, you can change itno matter what, just make sure it is the file name where the PHP coding to process the login is the same. So, for WHM logins, you can name it the basic, "WHM.php" (you can use uppercase or lowercase, of course)

Now, in the script (PHP coding), you'll need ot change the port numbers! This is so it logs in to the right service, otherwise it'll just go for cPanel, that was used in this tutorial. The following are port numbers for each service, that replaces "website.com:2083" or "website.com:2082".

Standard WHM - 2086
Secure WHM - 2087
Standard Webmail - 2095
Secure Webmail - 2096

Now, for secure FTP web-broswer login, (in the PHP coding of the script) just make the following changes that apply to your needs:

+ "https://" with "ftps://"
+ "http://" with "ftp://"
+ "website.com:20XX" with your url/domain (for both entries)

Save and close!

----------------------------------------------------------------------------------------

I hope this helps all of you that need it! Feel free to post question/support needs here. ALSO, those familiar with this type of PHP scripting, you could make it (with very minor tweaks) make multible login processings with one .php file! Otherwise, to those whom do not know this coding as well, just use the examples
__________________
GamingHybrid is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
These users thank GamingHybrid for this great post!
azzor (March 2nd, 2007), harryb (April 16th, 2007), Patty (February 19th, 2007)
Old August 26th, 2006, 10:25 PM   #2 (permalink)
Registered User
Seasoned Poster
 
Joined in Apr 2006
36 posts
Gave thanks: 0
Thanked 0 times
That's a nifty little script! With a little tweaking you could make one form work for webmail, whm, and cPanel. I might use that. Thanks!

Clinton
__________________
Clintonweaver.com
Server Name: Pass58
Clinton564 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 27th, 2006, 12:43 AM   #3 (permalink)
Yabadabadoo
Super #1
 
Geoff's Avatar
 
Joined in Nov 2004
Lives in B.C., Canada
Hosted on Dedicated
1,011 posts
Gave thanks: 7
Thanked 28 times
could you not simply post the values instead of "creating" the whole login:passworddomain.com?
__________________
Geoff Ellis - Surpass Dedicated Server Customer
www.adepttechs.net
Geoff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 27th, 2006, 5:54 AM   #4 (permalink)
Bow before Surpass!
Super #1
 
Joined in Sep 2004
1,542 posts
Gave thanks: 91
Thanked 49 times
No problem Clinton564, hope it helps!

Quote:
Originally Posted by Geoff View Post
could you not simply post the values instead of "creating" the whole login:passworddomain.com?
What do you mean? If you mean just send the values to domain.com:2082 or so, no it won't work. The layout needs to be there... as I've tried it at first until this.
__________________
GamingHybrid is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 19th, 2007, 6:01 AM   #5 (permalink)
Bow before Surpass!
Super #1
 
Joined in Sep 2004
1,542 posts
Gave thanks: 91
Thanked 49 times
Incase this has been forgotten, BUMP. I miss my dedicated server...
__________________
GamingHybrid is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 19th, 2007, 7:59 AM   #6 (permalink)
Registered User
Excelling Contributor
 
Joined in Feb 2005
521 posts
Gave thanks: 79
Thanked 24 times
Very nice! I was looking for something like that, thank you.

What I actually want is a multiple server login form. I have 4 different servers, so I'd need to have a way for the client to select the server and then login. Is it possible. Does anyone know how to do it?
__________________
Patty

Pass 57 | Dime999 | SH 110
Patty is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 21st, 2007, 2:41 AM   #7 (permalink)
Bow before Surpass!
Super #1
 
Joined in Sep 2004
1,542 posts
Gave thanks: 91
Thanked 49 times
Quote:
Originally Posted by Patty View Post
Very nice! I was looking for something like that, thank you.

What I actually want is a multiple server login form. I have 4 different servers, so I'd need to have a way for the client to select the server and then login. Is it possible. Does anyone know how to do it?
Sorry for the delay. It is indeed possible! Here is a small example on how to do this:

Add the following to the form:
Code:
  <select name="host">
    <option value="00.0.000.000">Server 1</option>
    <option value="00.0.000.000">Server 2</option>
    <option value="00.0.000.000">Server 3</option>
    <option value="00.0.000.000">Server 4</option>
  </select>
As for the cpanel.php, add the variable $_POST["user"]. Here is the code bit you can replace:
PHP Code:
else if ($_POST["secure"] == 1){
    
header("Location: https://".$_POST["user"].":".$_POST["pass"]."@$_POST["host"]:2083");} 
else {
    
header("Location: http://".$_POST["user"].":".$_POST["pass"]."@".$_POST["host"].":2082");}

Hope that helps Just remember to replace the 00.0.000.000 with the correct ips or domain names (without the www. or the http://)
__________________
GamingHybrid is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
This user thanks GamingHybrid for this great post!
Patty (February 21st, 2007)
Old February 21st, 2007, 10:33 AM   #8 (permalink)
Registered User
Excelling Contributor
 
Joined in Feb 2005
521 posts
Gave thanks: 79
Thanked 24 times
Wonderful!! That's exactly what I need!
I'll try that. Tks a lot, GH!
__________________
Patty

Pass 57 | Dime999 | SH 110
Patty is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 21st, 2007, 1:35 PM   #9 (permalink)
Registered User
Excelling Contributor
 
Joined in Feb 2005
521 posts
Gave thanks: 79
Thanked 24 times
GH, works like a charm! Thank you so much!!

Now just one final silly question: how can I make cPanel open up in a new window so the user doesn't have to leave my site?

Tks a lot for this little gem and for you help.
__________________
Patty

Pass 57 | Dime999 | SH 110
Patty is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On