Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-27-2009, 03:28 PM   PM User | #1
phaltu420
New to the CF scene

 
Join Date: Jan 2009
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
phaltu420 is an unknown quantity at this point
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>
phaltu420 is offline   Reply With Quote
Old 01-27-2009, 03:53 PM   PM User | #2
A1ien51
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
A1ien51 will become famous soon enough
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]
A1ien51 is offline   Reply With Quote
Old 01-28-2009, 06:57 AM   PM User | #3
phaltu420
New to the CF scene

 
Join Date: Jan 2009
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
phaltu420 is an unknown quantity at this point
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
phaltu420 is offline   Reply With Quote
Old 01-31-2009, 12:10 PM   PM User | #4
phaltu420
New to the CF scene

 
Join Date: Jan 2009
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
phaltu420 is an unknown quantity at this point
seems like no one interested to help. or no one has actually a solution to help!!!
phaltu420 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:19 AM.


Advertisement
Log in to turn off these ads.