Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question stop posting the form in new window if login is incorrect(show an error msg instead)

    dear readers,

    the code below belongs to a form where users can input their username and password to login to their webmail service.

    it uses target="_blank" to open the new window for the logged in users. it also opens a new window even if the login information is incorrect. whereas it should be remaining in the current window displaying an error msg "Your login attempt failed!" without opening a new window.

    As you can guess, I am not very good in this.

    i posted it here cause maybe javascript may be introduced to solve this.

    help me out please.

    regards,
    karim


    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    </head>
    <body>

    <center><table width="200" border="0" cellspacing="2" cellpadding="0"><tr><td bgcolor="000000" width="100%" align=center><span class="grey"><font face=arial size=4><b>WebMail</b></span></font></tr></td></table></center><br>


    <br><br><br><center>
    <form action="Login.php" method="POST" target="_blank">
    <?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 />';
    }
    ?>
    <input type="hidden" name="domain" value="domain.com" size="20" /><br />
    <font face=arial size=2><b>Username: </b></font><input type="text" name="username" value="" size="20" /><br />
    <font face=arial size=2><b>Password: </b></font><input type="password" name="pass" value="" size="20" /><br />
    <?php

    echo '<input type="hidden" name="failurl" value="http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?failed=1">';
    ?>
    <select name="port" style="display:none;">
    <option value="2095">Webmail</option>
    <option value="2096">Secure Webmail</option>
    </select><br />
    <input type="submit" value="Login" />
    </form>

    <br><br><br></center>

    </body>

    </html>

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    The form has no clue if the data is correct so it will post to a new window.

    Only way you can make sure the data is correct is use an Ajax call to post back to the server. If it is, you can call window.open or post the form. If the login is incorrect you show an error message on the page.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts
    thanks for the reply A1.

    the form goes to login.php to check if the data is correct or not.

    as i am relatively new, can you please give an example of an ajax call?

    thanks in advance.

    regards,
    karim

  • #4
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts
    seems like no one interested to help. or no one has actually a solution to help!!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •