It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming PHP and MySQL Forum

cPanel Custom Login Script. I Need Help Modifying The Code.

Moderator: Malcolm

cPanel Custom Login Script. I Need Help Modifying The Code.

Postby mfdanna on Wed May 30, 2007 4:21 pm

Hello,

I need help with this code posted below and how to modify it. This is for a PHP script to have my customers log-in to their cPanel hosting area directly from my site. I know its not a brain buster since so many people seem to be up and running with it. However I am pulling the hair out of my head with it.

First code is the cpanel.php code that will be on the server
<?php
// make sure all needed information is provided
if($_POST['domain'] && $_POST['username'] && $_POST['pass'] && !($_GET['failed'] == "1")) {
$port = $_POST['port']; // sets the port number to login to
// Get the protocol to use for this connection
switch($port) {
case '2082': // cPanel
case '2086': // WHM
case '2095': // Webmail
$protocol = 'http://';
break;
case '2083': // Secure cPanel
case '2087': // Secure WHM
case '2096': // Secure Webmail
$protocol = 'https://';
break;
}
// Build the URL
$redirectlocation = $protocol.$_POST['domain'].':'.$port.'/login/?user='.$_POST['username'].'&pass='.$_POST['pass'].'&failurl='.$_POST['failurl'];
header ("Location: ".$redirectlocation); // Send URL
} else {
$error = 1;
header ("Location: ".$_POST['failurl']); // Send URL if all neede information is not provided
}
?>


I have no clue what to modify to make that work.


Second code is the form to call to the script for my site.

<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>

For some reason I see parts of the php string when i put that in the page. I am thinking because i am obvisouly not doing it right.

Thanks for all of the help! I will be ready with any info needed for someone to help me since I REALLY need to get this thing up and running.

Thanks!
mfdanna
 
Posts: 13
Joined: Thu Apr 19, 2007 4:15 pm
Location: houston, texas

Postby flabbyrabbit on Wed May 30, 2007 5:21 pm

Hello :) Where/when does the problem occur?? And what exactly is the problem??

Flabby Rabbit
Image
User avatar
flabbyrabbit
500+ Club
 
Posts: 706
Joined: Thu Jan 25, 2007 1:10 pm
Location: Midlands, England

hmm

Postby mfdanna on Wed May 30, 2007 5:23 pm

Yo,

The script is fine, I just dont know how to add the certain modifications to make it work?

sad i know.
mfdanna
 
Posts: 13
Joined: Thu Apr 19, 2007 4:15 pm
Location: houston, texas


Who is online

Users browsing this forum: No registered users and 0 guests

cron