please help me out in HTML.
can anyone teach me the codes of having a username and password in a html?

Recommended Answers

All 11 Replies

That would be something like that:

<form action="your_page.your_extention" method="post">
  <input type="text" name="username" /><br />
  <input type="password" name="password" /><br />
  <input type="submit" value="Sign in" name="submit" />
</form>

And here's the explanation:
First you have a '<form>' tag, and in it you have the 'action' attribute, which you set to whatever page is going to take care of the user/pass verification (i.e. a PHP script, or ASP), then you have the 'method' attribute, which can be either 'post' or 'get', the common use is 'post' since that is safer and better (I won't go into detail overhere).

Then you have 3 input fields, the first has the 'type' attribute set to 'text', which obviously means that you can input text, and the 'name' you can set to whatever you want, the second field has the 'type' set to 'password', which means that all you'll see is those 'dots' instead of text, and the third is the 'submit' button, which actually sends the form to the page you put in for the 'action', and the 'value' attribute is the text that you see on the button.

Obviously you can do much more, but this is a plain and simple login form...

P.S. I didn't reread this post, so there might be a typo or two ;)

Change password.html do your own link
this is a starting point it is not exactly what u want

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

<body>
<?php
// Define your username and password
$username = "Your username";
$password = "your password";

if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) {
?>
<form name="form" method="post" action="../password.html">
    <br /><input name="txtUsername" type="text" title="Enter your Username" size="10" /></p><br />
    <br /><input name="txtPassword" type="password" title="Enter your password" size="10" /></p>
    <p><input type="submit" name="Submit" value="Login" /></p>
</form>
<?php
}
else {
?>
<?php
}
?> 
</body>
</html>

wew, thnx .
i appreciate someone answered me, thnx.

u've mentioned about form sir.. how about in form?

wew, thnx .
i appreciate someone answered me, thnx.

u've mentioned about form sir.. how about in form?

What form?

please help me out in HTML.
can anyone teach me the codes of having a username and password in a html?

hey bro visit http://w3schools.com
its a place where you can learn basics for everything. It is managed by w3.org

Before you start following what they "teach" at w3schools, it pays to know a few things.
It's run by just a couple of guys. It has ABSOLUTELY NO CONNECTION WHAT SO EVER with W3C / w3.org at all. It is NOT run by w3.org . It's owners are cashing in on having a similar sounding name that makes you think it is related.

It has such a bad reputation among professionals that a group of people have created a site you really should visit, called http://w3fools.com/

Read it and weep.
Especially if you thought you'd learned to code correctly from it or recommended it to someone...

Before you start following what they "teach" at w3schools, it pays to know a few things.
It's run by just a couple of guys. It has ABSOLUTELY NO CONNECTION WHAT SO EVER with W3C / w3.org at all. It is NOT run by w3.org . It's owners are cashing in on having a similar sounding name that makes you think it is related.

It has such a bad reputation among professionals that a group of people have created a site you really should visit, called http://w3fools.com/

Read it and weep.
Especially if you thought you'd learned to code correctly from it or recommended it to someone...

That doesnt mean its a bad place to go and learn. Ive never been to w3.org. I know I have and my college tells students who are taking understanding pc to use w3schools to learn and test out basic web programming. Its kept well and the try it yourself with the edit option is a great tool for beginners to learn and experiment.

yes this script was excellent and i checked too and it was working fine

do you want a registration form where a user can create username and password or you want a login page?

To create a full-fledge login page there is a need of some server side languages which includes both front end like Asp.Net or PHP and back end like SQL Server which will be embedded in HTML code to create a dynamic login form, using simple HTML can only display a form or can say a static which cannot store any information for future purpose ...

Member Avatar for Del4eff

Before you start following what they "teach" at w3schools, it pays to know a few things.
It's run by just a couple of guys. It has ABSOLUTELY NO CONNECTION WHAT SO EVER with W3C / w3.org at all. It is NOT run by w3.org . It's owners are cashing in on having a similar sounding name that makes you think it is related.

It has such a bad reputation among professionals that a group of people have created a site you really should visit, called http://w3fools.com/

Read it and weep.
Especially if you thought you'd learned to code correctly from it or recommended it to someone...

Thanks drjohn, you've opened my eyes about w3schools :) I'm still a newbie in html and "correction" like that is something very usefull for me, so thanks again.

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.