login form looking for help - please

Author Topic: login form looking for help - please  (Read 1900 times)

Offline newbiedude77Topic starter

  • Trade Count: (0)
  • Newbie
  • *
  • Thank You 0
  • Posts: 3
  • Karma: 1
login form looking for help - please
« on: 02-21-2012, 05:46:49 »
   
Hello Im looking for help with my login form...So far I have coded that if I put in the correct password and username then I will getinto my site. I would like to have something whereby if I put in 3 failed attempts I get a message each time telling me how many attempts I have left and then no access.
After every failed attempt I want the textbox to clear aswel so i can enter in the next attempt......Thanks guys

All help would be very helpful...I have tried this for a few days now with success ......

here is my cose so far

<script language="javascript">

function passuser(form)
{
if (form.user.value=="tony" &&form.password.value=="hello")
{
window.alert("Hello tony")
location='http://www.google.com'

}
}
</script>
</head>

<body><center><br />



<form action="name" method="get">
<table width="300" height="200" border="1" cellpadding="5"cellspacing="5">
<tr>
<th colspan="2" scope="col"bgcolor="#6699FF"><center>LOGIN FORM</center></th>
</tr>
<tr>
<td width="120" align="center"> User Name</td>
<td width="140"><label>
<input type="text" name="user" id="user" />
</label></td>
</tr>
<tr>
<td align="center">Password</td>
<td><label>
<input type="password" name="password" id="password" />
</label></td>
</tr>
<tr>
<td align="center"><label>
<input type="reset" name="cmdClear" id="cmdClear" value="Reset" />
</label></td>
<td align="center"><label>
<input type="submit" name="enter" id="log" value="Login" onclick="passuser(this.form)" />
</label></td>
</tr>
</table>
</form>
</center>
</body>

Seo Forum

login form looking for help - please
« on: 02-21-2012, 05:46:49 »

Offline Vinil

  • Global Moderator
  • Trade Count: (0)
  • *****
  • Thank You 36
  • Posts: 301
  • Karma: 12
  • Gender: Male
  • I can and I Will
    • Boaters Directory
Re: login form looking for help - please
« Reply #1 on: 02-21-2012, 07:06:39 »
after completing if{}put an else condition that will display some alerts when credentials are not correct

« Last Edit: 02-21-2012, 23:53:24 by Vinil »

Offline newbiedude77Topic starter

  • Trade Count: (0)
  • Newbie
  • *
  • Thank You 0
  • Posts: 3
  • Karma: 1
Re: login form looking for help - please
« Reply #2 on: 02-21-2012, 09:34:42 »
Hi and thnks for your reply. I got the login form working ok but when I put a wrong password into the form my form page shuts down when viewing it on the net. The process works fine when testing it out on dreamweaver. any ideas? am i missing some code. All help would be great thank you. Here is my code now up to date:

<script language="javascript">
var counter = 2
function passuser(form)
{
if (form.user.value=="john" &&form.password.value=="hello")
{
 window.alert("Hello there")
 location='http://www.google.com'

}
  else if (counter <=0)
{
   window.alert("Access Denied")
   window.close()

 
}
else
 {
 window.alert("Username or Password is incorrect - You have " +counter+ " tries left")
     counter = counter - 1
return false;
  }
}






</script>
</head>

<body><center><br />


   
<form action="name" method="get">
  <table width="300" height="200" border="1" cellpadding="5"cellspacing="5">
    <tr>
      <th colspan="2"  scope="col"bgcolor="#6699FF"><center>LOGIN FORM</center></th>
    </tr>
    <tr>
      <td width="120" align="center"> User Name</td>
      <td width="140"><label>
        <input type="text" name="user" id="user" onFocus="this.value=''" value="" />
      </label></td>
    </tr>
    <tr>
      <td align="center">Password</td>
      <td><label>
        <input type="password" name="password" id="password" onFocus="this.value=''" value="" />
      </label></td>
    </tr>
    <tr>
      <td align="center"><label>
        <input type="reset" name="cmdClear" id="cmdClear" value="Reset" />
      </label></td>
      <td align="center"><label>
        <input type="submit" name="enter" id="log" value="Login" onclick="passuser(this.form)" />
      </label></td>
    </tr>
  </table>
</form>
</center>
</body>

Offline Vinil

  • Global Moderator
  • Trade Count: (0)
  • *****
  • Thank You 36
  • Posts: 301
  • Karma: 12
  • Gender: Male
  • I can and I Will
    • Boaters Directory
Re: login form looking for help - please
« Reply #3 on: 02-21-2012, 23:45:32 »
hey I got the issue with the code.You did a mistake.Do modify the code with this line
<form action="form.html">

check your code it must be like above I wrote.I checked  manually you put form action ="name" which is wrong .In action ,we use to put the url of page where it will be redirected after the page will be submitted .replace your code with above mentioned one and you will be get the desired results


Post Merge: 02-21-2012, 23:48:10

also i strongly recommend you please visit w3schools for the syntax of programming code .you have mistaken in  few more lines and learn javascript from there
to open a new site the code must looks like window.open("http://www.google.com")
« Last Edit: 02-21-2012, 23:52:07 by Vinil »

Offline newbiedude77Topic starter

  • Trade Count: (0)
  • Newbie
  • *
  • Thank You 0
  • Posts: 3
  • Karma: 1
Re: login form looking for help - please
« Reply #4 on: 02-22-2012, 04:35:11 »
Ok thanks for your help ill take that advice  :)

Offline Vinil

  • Global Moderator
  • Trade Count: (0)
  • *****
  • Thank You 36
  • Posts: 301
  • Karma: 12
  • Gender: Male
  • I can and I Will
    • Boaters Directory
Re: login form looking for help - please
« Reply #5 on: 02-22-2012, 04:36:37 »
its ok .Feel free to contact me in case any issue in web development.i will definitely try to solve the issues

 

Related Topics

  Subject / Started by Replies Last post
1 Replies
558 Views
Last post 10-11-2011, 06:40:11
by C.Rebecca
0 Replies
636 Views
Last post 11-18-2011, 04:22:35
by manvbf
0 Replies
1275 Views
Last post 06-29-2012, 08:53:53
by hirephp
0 Replies
426 Views
Last post 04-22-2014, 07:45:40
by webcreations
0 Replies
510 Views
Last post 05-07-2014, 11:03:40
by seolink1990