School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,112 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,998 people online right now. Registration is fast and FREE... Join Now!




Password help

 

Password help

kirbyfan101

5 Nov, 2009 - 02:42 PM
Post #1

New D.I.C Head
*

Joined: 30 Apr, 2009
Posts: 48


My Contributions
I need help setting a password for a login here is my code(i have no idea how to set a password with html yet):
CODE

<html>
<head>
<form action="" method=post>
name: <input type=text name="Username"><Br>
password: <input type="password" name="Password">
<p><input type=submit value="submit">
</form>
</head>
</html>


This post has been edited by kirbyfan101: 5 Nov, 2009 - 02:54 PM

User is offlineProfile CardPM
+Quote Post


neit

RE: Password Help

5 Nov, 2009 - 04:11 PM
Post #2

D.I.C Head
**

Joined: 13 Feb, 2009
Posts: 138



Thanked: 12 times
My Contributions
you will need some forum of server side scripting such as php and/or mysql to set a password. Check out some tutorials on it.
User is offlineProfile CardPM
+Quote Post

ravish012

RE: Password Help

5 Nov, 2009 - 10:40 PM
Post #3

New D.I.C Head
*

Joined: 5 Nov, 2009
Posts: 3



Thanked: 1 times
My Contributions
Hi,
There are two ways of doing this... one is by creating a DB n stuff like that.. the other one is something like this:

(index.html)
CODE
<?php
session_start();
$errorMessage = '';
if (isset($_POST['txtUserId']) && isset($_POST['txtPassword'])) {
if ($_POST['txtUserId'] === 'user' && $_POST['txtPassword'] === 'passwd123') {
$_SESSION['basic_is_logged_in'] = true;
header('Location: yourlocation.php');
exit;
} else {
$errorMessage = 'Sorry, wrong user id / password';
}
}


Insert it on your index page above the <html> tag

below this include your form :

CODE

<form method="post" name="frmLogin" id="frmLogin" action="index.php">
<table width="400"  align="center" cellpadding="2" cellspacing="2">
<tr>
<td width="150">User Id</td>
<td><input name="txtUserId" type="text" id="txtUserId"></td>
</tr>
<tr>
<td width="150">Password</td>
<td><input name="txtPassword" type="password" id="txtPassword"></td>
</tr>
<tr>
<td width="150"> </td>
<td><input type="submit" name="btnLogin" value="Login"></td>
</tr>
</table>
</form>

The username here is 'user' and the password is 'passwd123' .
Please note that this is a very basic user authentication which does not use databases and stuff...It makes use of POST variables and Session variables. smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 01:19PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month