embedd login form into website

Discussion in 'Tips/Tricks/Mods' started by giftsnake, Oct 27, 2009.

  1. giftsnake

    giftsnake New Member

    hi, i am trying to include the login of ispconfig3 into a website. my guess was:

    it did not work (obviously, otherwise i would not post it here :p)
    if someone has a working form, please post it here!
    Thanks in advance, giftsnake
  2. giftsnake

    giftsnake New Member

    hm, maybe i posted in the wrong forum :-/
  3. falko

    falko Super Moderator ISPConfig Developer

    What happens when you submit the form?
  4. giftsnake

    giftsnake New Member

    same as if i call the interface in the browser. the username and the password does not do anything
    Last edited: Nov 5, 2009
  5. giftsnake

    giftsnake New Member

    -> changed the variables in the submit-form to 'username' and 'passwort'
    what happens:
    the login button calls the index.php page with:
    i still get no login. any ideas?
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    The login form works with ajax, you can not use a external login form in ispconfig 3 withour rewriting the ispconfig login mechanism.
  7. giftsnake

    giftsnake New Member

    why is the following code in the mechanism:
    if(count($_POST) > 0)
    is it just for "login as <user>" from inside the panel?
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    A ajax request is a post request.
  9. giftsnake

    giftsnake New Member

    maybe i dont get it right...
    you implemented the 'post'login, but i still have to rewrite the mechanism?

    looks to me that i just have write the correct form to submit the data to the loginscript, right?
  10. till

    till Super Moderator Staff Member ISPConfig Developer

    No. Everything in ispconfig is loaded by ajax, so after the login, the ispconfig ajax scripts replace just some parts on the same html page that displays the login script and does not load the whole page again. So if your page is not the ispconfig outer html page, then nothing gets replaced and you dont get the ispconfig interface as the result.

    Also be aware that browsers block all cross domain post requests, so if your login form does not run on the same port and under the same domain then the ispconfig interfcae, all modern browsers will block any post data.
  11. briansmith

    briansmith New Member

    Hi, I am currently working on my thesis which involves a custom toolbar. This toolbar is activated once the user successfully logs in his/her gmail account. Basically very similar to the code you provided however, if its successfull it does not re-direct to one's email but displays a message that you have successfully logged in. If not successfull, it does not re-direct you to the gmail homepage but just lets you re-enter one's credentials. In addition how can I have another button which when clicked will log out?
  12. abdi

    abdi Member

    Has this been implemented now? Ie can I add a form on my website or just pass the username and passwort variables to AUTO login the user? Is there anyway I can do this?

    This is very important for me since i have a billing system with which I want users to use to access there ISPConfig accounts without having to type there logins ...
  13. webguyz

    webguyz Active Member HowtoForge Supporter

    Interested in this myself for the same reason, automate login from inside a main control panel. Anyone find a work around?

  14. webguyz

    webguyz Active Member HowtoForge Supporter

    Anyone ever find a solution or is it still not possible.

    If I could at least prefill the login form with the customers login and password and they would have to hit the button that would be ok. Been trying different things with no luck for a long time.
  15. LKTechnik

    LKTechnik New Member

    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.js"></script>
    <form name="ajaxform" id="ajaxform"  method="POST"  >
        <input type="hidden" name="s_mod" value="login">
        <input type="hidden" name="s_pg" value="index">
        <input name="username" id="username" value="" size="30" maxlength="255" type="text">
        <input name="passwort" id="passwort" value="" size="30" maxlength="255" type="password">
        <button type="submit" class="button" value=""  ><span>Anmelden</span></button>
    <script type="text/javascript">
        //callback handler for form submit
            var postData = $(this).serializeArray();
                url : 'https://isp.tld:8080/content.php',
                type: "POST",
                data : postData,
                xhrFields: {withCredentials: true},
            return false;
    ('Access-Control-Allow-Origin: http://www.lktechnik.ch');
    header('Access-Control-Allow-Methods: POST');
    header('Access-Control-Allow-Credentials: true');
    Tristen Russ and DDArt like this.
  16. webguyz

    webguyz Active Member HowtoForge Supporter


    Thanks for the login form for which works well. One thing I'm trying to do is have my customer login in once into my WHMCS billing system and I would automate logging in to my customers various cp's like cPanel, WebsitePanel, Helm, etc.

    With your form I can add some post variables and hide the username and password fields which I populated with my POST. Customer has to just hit the submit button and they are automaticaly logged into ISPconfig.

    Was wondering if it would be possible to auto submit the form after it has the variables, something I do with other cp's that I autolog into.

    I tried this on your form but it seems to be stuck in a loop:

    <SCRIPT LANGUAGE="JavaScript">

    Maybe a limitation of ajax, but it would be cool if its possible. If not just being able to autofill the form and present the end users a single button to hit is excellent. I know others have been looking for something like this for a long time.

  17. LKTechnik

    LKTechnik New Member

    yes its possible, and its easy...

    echo '<div class="borderbox" style="text-align:center;"><br />Einen Moment bitte Sie werden weitergeleitet...<br /><br />
    <img src="'
    .$system['url_img'].'ajax-loader.gif" alt="Bitte warten"><br /><br />

    <script type="text/javascript">

    function weiterleitung() {
        type: "post",
        url: "https://isp.tld:8080/content.php",
        data: "s_mod=login&s_pg=index&username=USERNAME&passwort=PASSWORD",
        xhrFields: {withCredentials: true}

    window.setTimeout("weiterleitung()", 100);



    to your data / Users data
  18. webguyz

    webguyz Active Member HowtoForge Supporter


    Tried your script without any changes. Figured I would at least get an error message or it would take me to a login screen. What happening is it gives me the message in Geman about your being forwarded and the last thing I see on the screen is: Bitte warten (please wait)

    Just stuck there.

    Tried replacing all the variables with my website info and hardcoded valid username and password and got the same results..

    Tried with FF and Chrome browsers.

  19. LKTechnik

    LKTechnik New Member

    Did you change the /usr/local/ispconfig/interface/lib/config.inc.local.php ?
    you also need jquery ...

    if you pres F12 in chrome you can switch to the
    network tab, then reloading the page with the script,
    did you se any error?
  20. webguyz

    webguyz Active Member HowtoForge Supporter

    I didn't have the line:

    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.js"></script>

    Once I added it was perfect!!

    Wish Till would include something like this for those who need to call ISPConfig from a cp or billing system.

    Thanks! You Rock :)

Share This Page