There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Login Form


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
M-Cheezy's Avatar
Junior Member with 7 posts.
 
Join Date: Feb 2007
Location: in your closet
Experience: Intermediate
09-Feb-2007, 07:41 AM #1
Question Login Form
Hello. I'm a senior in high school and am in a Web Design 3 class.

I just received a new project from my teacher: I need to help another teacher create a website. But he wants a login form so you would need a username and password to join his site. I have the basic code for a login form but I do not know what to do from that point. I guess I'm suppose to set a destination for the form. (If anybody knows what I'm trying to say ) Can somebody give me some HTML coding for that?

Thanks.
M-Cheezy
knight_47's Avatar
Senior Member with 1,187 posts.
 
Join Date: Mar 2006
Location: →
Experience: Um... Green?!
09-Feb-2007, 09:20 AM #2
This can be done in PHP, but depending on how advanced you need the thing to be, you can do a simple:

PHP Code:
<?php
if ($_POST['Submit'] AND $_POST['pass'] == "admin")
{
echo 
"welcome to the password protected page";
}
else
{
echo 
"get out of here!";
}
?>
Chris_E's Avatar
Senior Member with 296 posts.
 
Join Date: Feb 2006
Location: Wellingborough, UK
Experience: I have no idea what I don't know - how could I?
11-Feb-2007, 08:29 AM #3
I found a simple chunk of code on dynamicdrive by a guy called Rob Heslop.

Visit this link:

http://www.dynamicdrive.com/dynamicindex9/password.htm

The page is very easy to understand and allows you to put a few lines in your webpage and then go off to a different web page depending on what the username and password both are.

Hope its useful for you too.

Chris
knight_47's Avatar
Senior Member with 1,187 posts.
 
Join Date: Mar 2006
Location: →
Experience: Um... Green?!
11-Feb-2007, 11:57 AM #4
Just be careful with Javascript password protection, since it is client side, it is very easy to hack or bypass. PHP or using your .htaccess file would be much better.

Depending on what your trying to password protect, if it something important or sensitive, you should NOT use javascript.
M-Cheezy's Avatar
Junior Member with 7 posts.
 
Join Date: Feb 2007
Location: in your closet
Experience: Intermediate
12-Feb-2007, 07:15 AM #5
Thank you for your help. I don't completely understand the assignment, as I am only used to working out of an HTML book. I"ll add the code to my page and try to figure out how everything works.
namenotfound's Avatar
Computer Specs
Distinguished Member with 2,109 posts.
 
Join Date: Apr 2005
Location: New York
Experience: I know what I know, I am
12-Feb-2007, 05:10 PM #6
Quote:
Originally Posted by knight_47
This can be done in PHP, but depending on how advanced you need the thing to be, you can do a simple:

PHP Code:
<?php
if ($_POST['Submit'] AND $_POST['pass'] == "admin")
{
echo 
"welcome to the password protected page";
}
else
{
echo 
"get out of here!";
}
?>
Doesn't he want username AND password? You're only offering password. If you look here you can see I use both username and password. Here's the code:

PHP Code:
<?php
$user 
= ($_POST['user'] === 'YOUR_USERNAME_HERE');
$pass = ($_POST['pass'] === 'YOUR_PASSWORD_HERE');

if (
$user AND $pass) {
echo 
"<h2>The username and password are correct!!</h2>";
}
else {
echo 
"<h2>That is the wrong username and password</h2>";
}
?>
knight_47's Avatar
Senior Member with 1,187 posts.
 
Join Date: Mar 2006
Location: →
Experience: Um... Green?!
12-Feb-2007, 05:18 PM #7
Quote:
Originally Posted by namenotfound
Doesn't he want username AND password? You're only offering password. If you look here you can see I use both username and password. Here's the code:

PHP Code:
<?php
$user 
= ($_POST['user'] === 'YOUR_USERNAME_HERE');
$pass = ($_POST['pass'] === 'YOUR_PASSWORD_HERE');

if (
$user AND $pass) {
echo 
"<h2>The username and password are correct!!</h2>";
}
else {
echo 
"<h2>That is the wrong username and password</h2>";
}
?>
It was just an example for him to modify so it can fit his needs. But yeah, your example would have been better to start with.
M-Cheezy's Avatar
Junior Member with 7 posts.
 
Join Date: Feb 2007
Location: in your closet
Experience: Intermediate
13-Feb-2007, 07:24 AM #8
Alright, so when the username and password are put in, how do you get the site to remember the correct combination and where would the link go to? Do I need to set up a page specifically for that?
namenotfound's Avatar
Computer Specs
Distinguished Member with 2,109 posts.
 
Join Date: Apr 2005
Location: New York
Experience: I know what I know, I am
13-Feb-2007, 11:23 AM #9
The script has the correct combination in it already And you have to specify the link yourself.
M-Cheezy's Avatar
Junior Member with 7 posts.
 
Join Date: Feb 2007
Location: in your closet
Experience: Intermediate
14-Feb-2007, 07:14 AM #10
Okay, thank you. How about like...a "register for username" thingy, what if I put that link on, which code would I use to let them register? I already have a form complete to type in a username, password, e-mail, etc. I don't know what link to put there. Once I have most of the basic code put together, then I'll post it on here to see if I've done it right. It'll probably be another month before I get it all together though.
namenotfound's Avatar
Computer Specs
Distinguished Member with 2,109 posts.
 
Join Date: Apr 2005
Location: New York
Experience: I know what I know, I am
14-Feb-2007, 09:18 AM #11
Well for that you'd most likely would want to use a database. That way when they select their desired username and password, it's stored in the database.
M-Cheezy's Avatar
Junior Member with 7 posts.
 
Join Date: Feb 2007
Location: in your closet
Experience: Intermediate
15-Feb-2007, 07:28 AM #12
Alright, I'll save that page for later; I guess you have to buy the database, but that's not my job
knight_47's Avatar
Senior Member with 1,187 posts.
 
Join Date: Mar 2006
Location: →
Experience: Um... Green?!
15-Feb-2007, 09:05 AM #13
Quote:
Originally Posted by M-Cheezy
Alright, I'll save that page for later; I guess you have to buy the database, but that's not my job
No you don't buy databases, you just need to probably buy a host that supports PHP, and MySql, unless you already have one.
ThaBrudda's Avatar
Member with 77 posts.
 
Join Date: Apr 2003
15-Feb-2007, 11:12 AM #14
Not Meaning to Thread Hijack....
But this is what I am looking for too. (I actually logged on to ask specifically about this topic.)

I have a website that I am hosting on 1and1. It has protected directories, mySQL databases, .htaccess, and can run php scripts.

I want to set up a Member's Area and do the following:

1. Require a username and password for access, unique to each user. I need a form for them to fill out, with their info and requested user name and password (that I guess I would store in a mySQL database on the server, right?).

2. Require authentication or authorization from me to access the area - meaning I want to know who I am giving access to.

From reading this thread, I gather that I will need to us php and a mySQL database. 1and1's FAQ's and tutorials on how to do this are woefully lacking.

What sites or books would you recommend for me to learn how to do this? (Something that does not assume that I am a mySQL or php whiz would be very helpful ).

TIA,

ThaBrudda
namenotfound's Avatar
Computer Specs
Distinguished Member with 2,109 posts.
 
Join Date: Apr 2005
Location: New York
Experience: I know what I know, I am
15-Feb-2007, 12:21 PM #15
Quote:
Originally Posted by knight_47
No you don't buy databases, you just need to probably buy a host that supports PHP, and MySql, unless you already have one.
It depends on his host. Some offer a database as an upgrade (php with no database for a basic plan).

But also, you could store the user/pass in a flat file type of database (.txt file)
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 04:54 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.