Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    Mar 2008
    Posts
    7

    Default Webmail login script redirect on failure

    Hello,

    I have the followig code below that will login into the domain's webmail. The code is on a custom login page domain.com/maillogin.php. The code works fine. The only problem is if a user enters a wrong user/password, they get redirected to the default webmail login page, http://domain.com:2095/login/. I would like to have it go to the domain.com/maillogin.php page. I've been searching around for a solution with no luck thus far. Any help would be great.

    Lance

    <?php

    #Webmail
    $protocol = 'http';
    $port = 2095;


    <html>
    <b>cPanel Login</b><br>
    <?php
    if ($_GET['failed'] == "1") {
    echo "Your login attempt failed!";
    }
    echo "<form action=\"" . $protocol . "://";
    echo $_SERVER['HTTP_HOST'] . ":" . $port . "/login/\" ";
    echo "method=POST>";
    ?>
    User: <input type=text name=user><br>
    Pass: <input type=password name=pass><br>
    <?php
    echo "<input type=hidden name=failurl value=\"http://" ;
    echo $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
    echo "?failed=1\">";
    ?>
    <input type=submit value=Login>
    </form>
    </html>

  2. #2
    Member LiNUxG0d's Avatar
    Join Date
    Jun 2003
    Location
    Gatineau, Quebec, Canada
    Posts
    206

    Default

    Hey there Lance,

    If you're submitting data to http://www.domain.com:2095/login/ well, cPanel will take control of what returns will occur. Short of re-coding this thing to submit in the background (AJAX-style) there isn't a way of getting what you want. Technically, if you edited the cPanel files you could tell it where to go, but I don't think you should be doing that for many reasons.

    I - personally - would make a script that curls the URL with the username and password, checks it to see if it will log in (by regex may I suggest) and then if successful, can log you in automagically by sending the user to the same URL via header() redirect.

    I replied to someone with some code today, which is up your alley:

    http://forums.cpanel.net/showthread.php?t=77540

    The problem is the submission to port 2095/login/. That page is what will control the return.

    Let me know if I've been of any assistance.

    Warmest regards,
    http://www.okteck.com/
    The best web hosting, reseller hosting and dedicated server packages!

  3. #3
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    If the failurl parameter is not working correctly for you, please submit a support ticket: http://tickets.cpanel.net/submit

  4. #4
    Member LiNUxG0d's Avatar
    Join Date
    Jun 2003
    Location
    Gatineau, Quebec, Canada
    Posts
    206

    Default

    Hi,

    Since the failurl is - obviously - a parameter cPanel supports (sorry; didn't know), try typing it in concretely instead of abstractly. Try actually typing the URL your failurl should go to, and not the PHP version of it.

    PHP Code:
    <?php
    echo "<input type=hidden name=failurl value=\"http://" ;
    echo 
    $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
    echo 
    "?failed=1\">";
    ?>

    Becomes:

    <?php
    print "<input type='hidden' name='failurl' value='http://www.domain.com/URI?failed=1'>";
    ?>
    By doing this, you can rule out if it's a problem with the actual PHP output. Just to see/debug.

    Just a thought,
    http://www.okteck.com/
    The best web hosting, reseller hosting and dedicated server packages!

Similar Threads & Tags
Similar threads

  1. Cpanel webmail login script
    By ahmadtrco in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 12-05-2006, 08:30 AM
  2. Webmail login Script
    By valtea in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 07-20-2004, 04:54 AM
  3. Login Script for Cpanel Webmail
    By SatuPortal.com in forum cPanel and WHM Discussions
    Replies: 14
    Last Post: 02-07-2004, 09:34 PM
  4. redirect webmail login url
    By |Noname| in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 12-03-2003, 08:04 AM
  5. Webmail Login Script
    By GrumWSmith.net in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 04-15-2003, 05:43 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube