PDA

View Full Version : Add new pop up function please



Pontiac_tonz
Oct 28th, 2009, 10:49 PM
I have a simple log on script which redirects the user to their page. It is not secure and is not ment to be.

I would like to have the page open in a new window, so that the page where they entered their user name and password is still there when they close the page they were re-directed to.

The script as is stands is

external file::::


!-- Begin
function Login(){
var done=0;
var username=document.login.username.value;
username=username.toLowerCase();
var password=document.login.password.value;
password=password.toLowerCase();
if (username=="aa" && password=="aa") { window.location="brett/index.php"; done=1; }
if (username=="sue" && password=="stu") { window.location="clients/corvette_cafe/"; done=1; }
if (username=="brock" && password=="zilla") { window.location="clients/brockzilla/brockzilla.html"; done=1; }
if (done==0) { alert("Invalid login!"); }
}
// End -->



The script on the page that the form is on is



<form class=login name=login>
<p>Username: <br /><input name=username type='text' size='20'><br />
Password: <br /><input name=password type=text size='20'></p>
<p class=login><input name=Submit type=button type=text value=Submit onClick="Login()"></p>
</form>





As you can see, very simple - but works great for my purpose.

Thanking you in advance.


Tonz :thumbsup:

fbelzile
Oct 28th, 2009, 11:38 PM
Hi, its a quick fix. Here you go:



!-- Begin
function Login(){
var done=0;
var username=document.login.username.value;
username=username.toLowerCase();
var password=document.login.password.value;
password=password.toLowerCase();
if (username=="aa" && password=="aa") { window.open('brett/index.php'); done=1; }
if (username=="sue" && password=="stu") { window.open('clients/corvette_cafe/'); done=1; }
if (username=="brock" && password=="zilla") { window.open('clients/brockzilla/brockzilla.html'); done=1; }
if (done==0) { alert("Invalid login!"); }
}
// End -->

Philip M
Oct 29th, 2009, 10:16 AM
!-- Begin will throw an error.

The <!-- and //--> comment (hiding) tags have not been necessary since IE3. :eek:

"Dives sum, si non redo eis quibus debeo. - I am a rich man as long as I do not pay my creditors"

Pontiac_tonz
Nov 1st, 2009, 10:31 PM
A HA - never thought of that ( DUH ) - many thanks for the help - Tonz