HazMat Hosting Posted August 6, 2007 Share Posted August 6, 2007 Heres the script i have right now: <?php#Login Configuration#cPanel$protocol = 'http';$port = 2082;#Secure cPanel#$protocol = 'https';#$port = 2083;#WHM#$protocol = 'http';#$port = 2086;#Secure WHM#$protocol = 'https';#$port = 2087;#Webmail#$protocol = 'http';#$port = 2095;#Secure Webmail#$protocol = 'https';#$port = 2096;?><html><?phpif ($_GET['failed'] == "1") {?><font color='#FF0000'>Your login attempt failed!</font><?php}print "<form action=\"" . $protocol . "://" . $_SERVER['HTTP_HOST'] . ":" . $port . "/login/\" method=POST>";?><font color='#D0D0D0'>User:</font><br> <input type=text name=user><p><font color='#DODODO'>Pass:</font><br> <input type=password name=pass><p><?phpprint "<input type=hidden name=failurl value=\"http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?failed=1\">";?><input type="submit" value="cPanel Login" target="_blank"></html> As you probably noticed this script can be used for more that cpanel.I would like to use it for webmail AND cPanel at the SAME time.I want it to have 2 login buttons so i can click cPanel or Webmail, but only 1 spot for username and password.Thanks in advance to anyone that helps me,HMH Link to comment Share on other sites More sharing options...
justsomeguy Posted August 6, 2007 Share Posted August 6, 2007 If you want to use PHP to do this, you'll have to use a library like cURL to send a post request to the appropriate login page. It would be easier to just have Javascript change the form action based on whatever you select. So you could have a group of radio buttons or a select menu where the user chooses which system to log in to, and some Javascript code could just update the form action to point to the correct place. It looks like cPanel or WHM always look for a field called "user" and one called "pass", so you need fields called "user" and "pass" also. The login script is always in the /login/ directory. You could have an id on the form and have a series of radio buttons or a select menu to update the action.<form id="login_form" method="post" action=""><input type="radio" onclick="document.getElementById('login_form').action = 'https://domain.com:2083/login/';"> cPanel Link to comment Share on other sites More sharing options...
HazMat Hosting Posted August 6, 2007 Author Share Posted August 6, 2007 well the problem comes wen people have javascript disabledisnt there a way to set $cPanel = then the login button for cpanel and then set $webmail = the login button for webmailthen: if ($cpanel) { #cPanel $protocol = 'http'; $port = 2082; }elseif ($webmail) { #Webmail $protocol = 'http'; $port = 2095; }else ($_GET['failed'] == "1") { <font color='#FF0000'>Your login attempt failed!</font> } Sorry for my BAD php i am still learning. I hope its good enough to understand it. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 6, 2007 Share Posted August 6, 2007 Well yeah, you can have PHP determine which button you clicked on and execute some code. The problem is the code you need to execute. This isn't going to do anything: $protocol = 'http'; $port = 2095; You would need to use the cURL library to send a post request to the appropriate page with the same username and password that they just typed in. There is also a way to send a post request without cURL, you can read about that here:http://netevil.org/blog/2006/nov/http-post...hp-without-curlThe body of the request (the data) would need to be something like this: $data = "user=" . urlencode($_POST['user']) . "&pass=" . urlencode($_POST['pass']); Link to comment Share on other sites More sharing options...
HazMat Hosting Posted August 6, 2007 Author Share Posted August 6, 2007 well could the username and password form be on a separate page and then have it in an iframe on the login page. and below the iframe on the login page could be the 2 submit buttons and depending on which one you click it could do something different with the form. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 6, 2007 Share Posted August 6, 2007 An iframe doesn't help. Either use Javascript to change the form action before the form gets submitted, or use PHP to send a post request to the correct login page. Link to comment Share on other sites More sharing options...
HazMat Hosting Posted August 6, 2007 Author Share Posted August 6, 2007 alright well i dont wanna do javascript cause that would be pointless for everyone that doesnt use javascriptand that cURL seems quite insecure so idk what i will do but ill let you know wen i figure it out Link to comment Share on other sites More sharing options...
Synook Posted August 8, 2007 Share Posted August 8, 2007 Don't worry 98% of web users have JavaScript, and for the rest you could always just provide a <noscript> option with a second form... Link to comment Share on other sites More sharing options...
HazMat Hosting Posted August 10, 2007 Author Share Posted August 10, 2007 its all good my friend rewrote the script for me.now it has Client Login at the top then below cPanel Login and a little check box and then webmail login and a little check box.you check one of the boxes and click login and then the login form comes up and you can login. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.