View Full Version : password for access to a web page
FCarol
01-16-2006, 12:54 PM
Hi...if I should not ask here..sorry, if its ok, THANK YOU.
I've been trying for several days now to creat a password "fonction" for access to a web page.
All I need is to verify that they enter the right password but I dont know how to get the Variable they enter to compare it with what I want...
I need a fonction that can do...
if password=X
continue on page
else goto home.....
:gaa:
I"ve looked on tutorials and information pages and I just dont get it....
THanks.
ChrisK
01-16-2006, 02:30 PM
Hi...if I should not ask here..sorry, if its ok, THANK YOU.
I've been trying for several days now to creat a password "fonction" for access to a web page.
All I need is to verify that they enter the right password but I dont know how to get the Variable they enter to compare it with what I want...
I need a fonction that can do...
if password=X
continue on page
else goto home.....
:gaa:
I"ve looked on tutorials and information pages and I just dont get it....
THanks.
Do you know what programming language you will be using?
FCarol
01-16-2006, 03:03 PM
Oops, I forgot to say how I was writting this...DUH!!!
I am trying to write it with HTML and I was looking on the net and all I could find for passwords was using Javascript. I am working in Frontpage.
ChrisK
01-16-2006, 03:06 PM
Oops, I forgot to say how I was writting this...DUH!!!
I am trying to write it with HTML and I was looking on the net and all I could find for passwords was using Javascript. I am working in Frontpage.
Doing this in JS is not very secure. I would suggest using a server-side language such as PHP, ASP, CGI, etc.
Who is your current hosting provider?
As ChrisK said, if you want to actually secure the page, Javascript is not a good idea since it is visible by looking at the source code of the file. If your host supports PHP you can accomplish this very easily. I don't know ASP so I'm not sure how hard it is there. Many hosts also support password protecting directories with .htaccess. Which host/package do you use?
ChrisK
01-16-2006, 05:02 PM
As ChrisK said, if you want to actually secure the page, Javascript is not a good idea since it is visible by looking at the source code of the file. If your host supports PHP you can accomplish this very easily. I don't know ASP so I'm not sure how hard it is there. Many hosts also support password protecting directories with .htaccess. Which host/package do you use?
ok...no problem...I'm an ASP guy. :)
FCarol
01-16-2006, 07:44 PM
http://www3.sympatico.ca/carol.charpentier/
pardon my french...hehehe, but this is what I am working on and I started this about 10days ago. Its my first ever, before I did not know how to make a web page but I have good knowledge about programming (was a programmer way back when). I dont know anything about those languages you are talking about, I barely know HTML. Which would be the simplest for me to learn?
ChrisK
01-16-2006, 11:17 PM
Like I said, I'm an ASP guy, so I think ASP is easier then PHP...but if you have a programming background...it really don't matter, same logic.
I'm not sure what sympatico supports. If it supports PHP I can make you a quick script to do what you want. Create a file named test.php and put the following inside:
<?php
echo "Test";
?>
Upload it and open the page in your browser. If PHP is on there you should see a blank page with the word Test on it. If you see the entire block of code there then the server doesn't support PHP.
ChrisK
01-17-2006, 04:41 PM
I'm not sure what sympatico supports. If it supports PHP I can make you a quick script to do what you want. Create a file named test.php and put the following inside:
<?php
echo "Test";
?>
Upload it and open the page in your browser. If PHP is on there you should see a blank page with the word Test on it. If you see the entire block of code there then the server doesn't support PHP.
And code for ASP:
<%="Hello World">
kibboy
01-17-2006, 09:52 PM
I'd post .NET but I don't think you could get the code down to less than 6 lines for a "hello"! (Sad aint it)
Hey Chris, dont' you need the "%>" to close that code out?
kibb
ChrisK
01-17-2006, 10:00 PM
I'd post .NET but I don't think you could get the code down to less than 6 lines for a "hello"! (Sad aint it)
Hey Chris, dont' you need the "%>" to close that code out?
kibb
yep, sorry your right.
<%="Hello World"%>
Aristera
01-18-2006, 01:35 AM
Is PHP and ASP each best for a certian area or are they about the same in everything?
ChrisK
01-18-2006, 07:47 AM
Is PHP and ASP each best for a certian area or are they about the same in everything?
Everyone has their own opinion. But ASP was made to run on a Windows Server and PHP was made to run on Linux/UNIX..then someone developed a porting software so that now each OS support both.
For example, my hosting services - Windows Server, supports both ASP, ASP (1.1 & 2.0), PHP, CGI, PERL, mySQL, MSSQL and Access.
Whereas, on most Linux/UNIX platforms, they still only offer support for the classics: PHP, CGI, PERL and mySQL.
When it comes down to it, you need to look at what your host supports and such runs best on the server. Where as in the case of my services, I support both ASP and PHP, I would suggest ASP because ASP was made of the Windows OS.
FCarol
01-18-2006, 06:43 PM
I have looked on the server information and they mention that bell.ca supports php and asp.
I will go check to see if I can find a tutorial for php and asp...
thanks.
ChrisK
01-18-2006, 06:53 PM
If you have MSN or YIM I can send you the code to do what you want.
FCarol
01-18-2006, 08:06 PM
*cries*...I feel so stupid....I tried both examples and they did not work.
1) can I work with either ASP or PHP in Microsoft Frontpage?
2) do I include the coding for asp or php in my normal html page?
3) would it be considered like a subroutine I would call up with a link?
I am soooo confused..
...and feel free to send the coding with the email from my webpage
http://www3.sympatico.ca/carol.charpentier/
Yes you can encorporate PHP or ASP with HTML. You can work with it in FrontPage, but you have to type in the code yourself. If you only want the webpage to verify user input against one or more static usernames/password then it's relatively easy to do. You can include ASP or PHP in HTML pages. You just need to rename the file to _____.asp or ____.php
Edit: I'll whip up something and post it. You can play around with it.
Here's something I whipped up. I haven't tested it out yet, but I will soon. I just have something else I need to do.
1. Code for the login page. You can obviously modify this to fit the design of your page.
<html>
<head>
<title>Password Sample</title>
</head>
<body>
<form method="POST" action="login.php">
Username: <input type="text" name="username" size="20"><br>
Password: <input type="text" name="password" size="20">
<p><input type="submit" value="Submit" name="Login"></p>
</form>
</body>
</html>
2. Paste this into a seperate file named login.php
<?php
//Nuke Login System
//Start Session
session_start();
//Define Static Username and Password
$userREAL = "Nuke";
$passREAL = "Passy";
//Get User Variables From Form
$username = $_POST['username'];
$password = $_POST['password'];
//Check Username and Password
if ($username == $userREAL && $password == $passREAL) {
$_SESSION['USERNAME'] = $username;
$_SESSION['PASSWORD'] = $password;
header("Location: secretpage.php");
}else{
echo "Incorrect Username or Password";
}
?>
3. Put this at the very top of secretpage.php (the page you want to protect)
<?php
//Check for Access
session_start();
//Establish Static Username and Password
$userREAL = "Nuke";
$passREAL = "Passy";
//Establish and Check SESSION Variables
$username = $_SESSION['USERNAME'];
$password = $_SESSION['PASSWORD'];
if ($userREAL != $username || $passREAL != $password) {
header("Location: accessdenied.php");
}
?>
If you change any of the page names, you'll need to change them in the code as well. I realize I'm not using includes or anything, and that it may not be the most efficient script in the world, but since this is just a simple script I think this should suffice and be secure. If you wanted you could stick the username/password in a seperate file and then include that file...but I think that this should do fine.
Edited 7:59PM - Jan 18
ChrisK
01-18-2006, 08:44 PM
If the examples didn't work, then no .asp or .php file will work on the server.
If you entend to truly secure the site from others I would recommend looking at a web hosting service that supports password protected directories.
Woops... I completely missed the part where you said the examples didn't work. If you had the file extensions named correctly (.php or .asp depending on the code you were using) then you'll have to find another webhosting solution.
FCarol
01-18-2006, 11:26 PM
OK..this is what I did,
Here's something I whipped up. I haven't tested it out yet, but I will soon. I just have something else I need to do.
I entered the code on my membres.htm page.
1. Code for the login page. You can obviously modify this to fit the design of your page.
<html>
<head>
<title>Password Sample</title>
</head>
<body>
<form method="POST" action="login.php">
Username: <input type="text" name="username" size="20"><br>
Password: <input type="text" name="password" size="20">
<p><input type="submit" value="Submit" name="Login"></p>
</form>
</body>
</html>
2. Paste this into a seperate file named login.php
I then created this page named login.php
<?php
//Nuke Login System
//Start Session
session_start();
//Define Static Username and Password
$userREAL = "Nuke";
$passREAL = "Passy";
//Get User Variables From Form
$username = $_POST['username'];
$password = $_POST['password'];
//Check Username and Password
if ($username == $userREAL && $password == $passREAL) {
$_SESSION['USERNAME'] = $username;
$_SESSION['PASSWORD'] = $password;
header("Location: secretpage.php");
}else{
echo "Incorrect Username or Password";
}
?>
3. Put this at the very top of secretpage.php (the page you want to protect)
I then added this at the uppermost top of my membres2.htm page.
Is that suppost to be correct?
<?php
//Check for Access
session_start();
//Establish Static Username and Password
$userREAL = "Nuke";
$passREAL = "Passy";
//Establish and Check SESSION Variables
$username = $_SESSION['USERNAME'];
$password = $_SESSION['PASSWORD'];
if ($userREAL != $username || $passREAL != $password) {
header("Location: accessdenied.php");
}
?>
added to one, created one and added to another, 2 htm files and 1 php file.
If you change any of the page names, you'll need to change them in the code as well. I realize I'm not using includes or anything, and that it may not be the most efficient script in the world, but since this is just a simple script I think this should suffice and be secure. If you wanted you could stick the username/password in a seperate file and then include that file...but I think that this should do fine.
Edited 7:59PM - Jan 18
ChrisK
01-18-2006, 11:32 PM
OK..this is what I did,
Ok, but it won't work because your host don't support PHP.
shoombool_tala
01-19-2006, 04:40 AM
you can try using a Java Applet. From the looks of the site I can see that security is not THAT Much of an issue. So maybe this simple script will do the job.
http://www.javaside.com/u_tpassword.html
the only downside of this is that once the person logs in, they can simple copy the location and give it to others so they can see it as well. So once again it comes down to how bad you want this file secure!!!! if you really want it secure just like how others suggested i would recommend getting a cheap hosting plan (around $7/month) that supports php/asp and file permissions.
FCarol
01-19-2006, 11:28 AM
The password really is for the non members to not wander in and get some emails and phone numbers. I will check out Java applet and if that becomes non sufficient, I will look into getting another host...eventually, these pages will be elsewhere. I am doing this for free to start me on web page creation and I need something to practice with.
Thank you all for replying to my questions. I really appreciate the help:))
vBulletin® v3.7.3, Copyright ©2000-2009, Jelsoft Enterprises Ltd.