Hi there, could anyone help me how to log in to a new html page? Like, when I click on log in button, it brings me to a new page. I tried several methods but didn't work.
Thanks in advance.

<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" title="style" />
<title>Identify Users</title>
<script type="text/javascript">
function validatePwd(theform){
if(theform.passwd.value==""){
alert("Please enter a password")
theform.passwd.focus()
return false
}
if(theform.passwd.value !=12345){
alert("Password incorrect")
theform.passwd.focus()
theform.passwd.select()
return false
}
return true
}
</script>
</head>
<body>
<h1 id="firsth1">Identify Users</h1>
<form onsubmit="return validatePwd(this)" id="loginform">
<fieldset>
<legend>Log in</legend>
<p>Please enter your User ID and Password to access</p>
<label for="username">
<input type="text" name="username" id="username" tabindex="1">User ID:</label>
<label for="passwd">
<input type="password" name="passwd" id="passwd" tabindex="2">Password:</label>
<label for="submit">
<input type="submit" class="submit" value="Log in" /></label>
<label for="reset">
<input type="reset" class="reset" value="Reset" /></label>
</fieldset>
</form>
</body>
</html>

I see you coding in js.

Well my first thought would be is to add a simple gotoURL function. But since you want to validate the password first, i would recommend handling it all through PHP.

i just tried it, yet it said password incorrect!

so it seems to me like its working.

you may want to include the dtd:
<code>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</code>

if there's none that make's weird things on the browsers.

on the othe had the user id is after the field same with password.

you may try this:

<code>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<link rel="stylesheet" type="text/css" href="style.css" title="style" />
<title>Identify Users</title>
<script type="text/javascript">
function validatePwd(theform){
if(theform.passwd.value==""){
alert("Please enter a password")
theform.passwd.focus()
return false
}
if(theform.passwd.value !=12345){
alert("Password incorrect")
theform.passwd.focus()
theform.passwd.select()
return false
}
return true
}
</script>
</head>
<body>
<h1 id="firsth1">Identify Users</h1>
<form onsubmit="return validatePwd(this)" id="loginform">
<fieldset>
<legend>Log in</legend>
<p>Please enter your User ID and Password to access</p>

<label for="username">User ID:</label>

<input type="text" name="username" id="username" tabindex="1">

<label for="passwd">Password:</label>

<input type="password" name="passwd" id="passwd" tabindex="2">


<input type="submit" class="submit" value="Log in" />

<label for="reset">
<input type="reset" class="reset" value="Reset" /></label>
</fieldset>
</form>
</body>
</html>
</code>

plus i've just realised that there's no action nor method on the form, it might have got somthing to do.

hope this has been of some help

Thanks u everyone, my coding is just for usability testing, that's why i didn't put too much coding and didn't do properly. And i am not a web developer, so i don't knw much about it. What i need for my testing is when click on "log in" it should go to new page but it doesn't work that way, pls help me. Password to login is 12345, but it goes nowhere. Thanks

use this line instead of return true in your js code:

theform.action="anotherpage.php";

i agree with shanti. it might work. hey u can also do that use a form tag and put the fields in it and place teh validation code in a new file with stuf u want on it. then redirect teh submited code to teh new page by teh action in form tag.
let me make it clear.
<form action="newpage.html" action="post"> it will work i think :)

use this line instead of return true in your js code:

theform.action="anotherpage.php";

Hi,
Shanthi

is it work in a html page

yes buddy it will work i guess. u shud try.

ya i just tried it

its working

but actually i dont know

html or any script regaurding

webdesigning

but i hvae created many blogs

by using tools provided by different sites

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.