...

View Full Version : Java/PHP Login Form In Popup Window



Antec
06-12-2008, 01:44 PM
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
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:



//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

kosstr12
06-13-2008, 03:07 AM
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.

boscharun
05-15-2011, 11:20 AM
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/94/p/general/popup-box-for-login-screen.html

AndrewGSW
05-15-2011, 11:53 AM
<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!!! :eek:

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

[eval() aarghh (again)]

AndrewGSW
05-15-2011, 12:01 PM
You need to use ajax.
Why ?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum