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 5 of 5
  1. #1
    New Coder
    Join Date
    Jun 2007
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Java/PHP Login Form In Popup Window

    I am having trouble getting this code to work correctly. What I am trying to do is on my site i will have a button that will open this popup window with a login form and what i would like it to do is when the form is submitted i want the window to close and the main page to redirect to whatever page i would like it sent to. And if the login information is wrong i would like the popup window to stay open and say that it is wrong in red letters at the top.

    Here is the code for the popup window:

    PHP Code:
    <?php
    if($target == "LogIn") {

    if(
    $view == "Form") {
    echo 
    '
    <script language="JavaScript" src="window.js">
    </SCRIPT>
    <style type="text/css">
    <!--
    body {
        background-color: #000000;
    }
    -->
    </style>
    <FORM action="index.php?act=Login&CODE=50" onSubmit="javascript:login();" method="post" name="mlogin">
      <p>
        <font face="verdana" color="#76a5d5" size="1"><B> Username: </b></font><INPUT class="textInput1" style="border: 1px solid #76A5D5; font-family: verdana, helvetica, sans-serif; font-size: 11px; padding: 2px; vertical-align: middle; margin: 0; width: 80px" type="username" size="25" name="username" value="Username"/>
        <br>    
        <FONT face="verdana" color="#76a5d5" size="1"><B> Password:&nbsp; </b></font><INPUT class="textInput1" style="border: 1px solid #76A5D5; font-family: verdana, helvetica, sans-serif; font-size: 11px; padding: 2px; vertical-align: middle; margin: 0; width: 80px" type="password" size="25" name="password" value="*******"/> <INPUT type="image" src="images/login.jpg" ALT="Click Here to Login!" BORDER="0" ALIGN="middle" value="submit" name="submit">
      </p>
    </form>'
    ;
    }
    }
    ?>
    Code for the javascript:

    PHP Code:
    //Open up a new window with specific dimensions
    function info(URL) {
        
    day = new Date();
        
    id day.getTime();
        eval(
    "page" id " = window.open(URL, '" id "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=100,left = 300,top = 500');");
    }

    <!--
        function 
    login() {
            
    setTimeout('window.close()',2000);
            
    opener.location.href='/main/index.php';
        }
    //--> 
    Any help would be greatly appreciated

  • #2
    Regular Coder kosstr12's Avatar
    Join Date
    Apr 2007
    Location
    Woodstock, Georgia
    Posts
    428
    Thanks
    7
    Thanked 5 Times in 5 Posts
    I didn't know you could do that with pop-up windows. Anyway, it might be easier to make a new window open when the page loads, and make it look like a pop-up box. Everything would be alot easier like that.

  • #3
    New to the CF scene
    Join Date
    May 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Ready-made easy solution

    You need to use ajax. If you want to try building yourself, see tinybox which is a javascript popup box. You can show the login form in a popup box using it.

    If you don't want to go through all the trouble, a ready-made solution is available from here. Do go through the readme file to integrate it easily to any website.
    http://www.skipser.toolsbysk.com/p/9...in-screen.html

  • #4
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    <style type="text/css">
    <!--
    body {
    background-color: #000000;
    }
    -->
    </style>

    <!-- are HTML comments - you can't use them within <style> tags.

    The (deprecated) font tag ??!!!! Aaaargh!!!

    Added: The same applies to your JS code <!-- this is HTML -->

    [eval() aarghh (again)]
    Last edited by AndrewGSW; 05-15-2011 at 10:58 AM.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #5
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    Quote Originally Posted by boscharun View Post
    You need to use ajax.
    Why ?
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS


  •  

    Posting Permissions

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