Go Back   Cyber Tech Help Support Forums > Software > Web Development & Graphic Design

Notices

Reply
 
Topic Tools
  #1  
Old August 18th, 2006, 04:42 PM
david_m david_m is offline
Member
 
Join Date: Apr 2006
O/S: Windows Vista
Location: Ireland
Posts: 62
Exclamation Registration system without database

Hey,I made my own registration form today in a html document and it looks like this:
Quote:
<html>
<head>
<title>Register To Recieve Full Access To Our Members Area</title>
</head>
<body>
<h3 align="center">Please Fill In The Form Below To Register</h3>
<p>You must register in order to recieve access to the members area. It only takes 30 seconds!</p>
<p>Titles with a (*) are required</p>
<form action="test.php" method="post">
<p>Username:<br><input type="text" name="srnm"></input></p>
<p>First Name:<br><input type="text" name="frstnm"></input></p>
<p>Last Name:<br><input type="text" name="lstnm"></input></p>
<p>Email Address:<br><input type="text" name="mldrs"</input></p>
<p>Country:<br><input type="text" name="adrs5"></input></p>
<p>Password:<br><input type="password" name="pswrd" min="6" max="12"></input></p>
<input type="submit" value="Submit"></input>
<input type="reset" value="Clear"></input>
</form>
</body>
</html>
and I made a php file like this:
Quote:
<html>
<head>
<title>Thank You For Registering <?php $frstnm ; ?></title>
</head>
<body>
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
?>
<?php
$frstnm = $_POST['frstnm'];
$pswrd = $_POST['pswrd'];
$srnm = $_POST['srnm'];
?>
<h2 align="center">Thank You For Registering <?php echo $frstnm ; ?>!</h2>
<p><?php echo $frstnm ; ?> you now have unlimited access to the members area!
<p>Here are your login details:
<br>
<b>Username:</b>
<?php echo $srnm ; ?>
<br>
<b>Password:</b><?php echo $pswrd ; ?>
</body>
</html>
When I enter in the details into test.html and click "Submit" it brings me to test.php and It says everything it should. I am very happy I have gotten that far as I only started learning php today.

I know you are able to and it is safer to use a database to hold all the info from the form but I want to use a .txt file. How make the info that was entered into the form to be sent to a .txt file in some directory and still go to the test.php page.

Then I want to be able to use a .htaccess file to protect the members directory and when you try and enter the members directory a box pops up saying enter your username and password and when you enter them in is scans throught the .txt file and tries to find a match. How can that be done?
Thank You!
Reply With Quote
  #2  
Old August 18th, 2006, 05:32 PM
oracle128's Avatar
oracle128 oracle128 is offline
Α Ω
 
Join Date: Oct 2000
O/S: Windows XP Pro
Location: Melbourne, Australia
Age: 24
Posts: 9,401
Quote:
I know you are able to and it is safer to use a database to hold all the info from the form but I want to use a .txt file. How make the info that was entered into the form to be sent to a .txt file in some directory and still go to the test.php page.
Text file data storage
Quote:
Then I want to be able to use a .htaccess file to protect the members directory and when you try and enter the members directory a box pops up saying enter your username and password
Passing variables from PHP to login via .htaccess protection (simply put, the way it works is you can place a username and password within the URL which automatically passes them to Apache to login)

Quote:
and when you enter them in is scans throught the .txt file and tries to find a match. How can that be done?
What you're wanting to do is use PHP to store username/password info in a text file, then use the PHP login script to read from those values? I may be wrong, but I don't think it can be done safely. Yes, I'm quite certain it's possible to do, but as far as I know, PHP needs access to the file; specifically, I don't think you can prevent user access to the file (via the .htaccess command IndexIgnore) without also blocking PHP's access.

If I'm right, it means that your project is a no-go, since if all users have access to the file, your password protection is useless.

But anyway, as for how it can be done (if you decide it's really what you want to do), it's quite easy; the file you want to write to simply needs to be named as, and have the format of, the regulation Apache .htpasswd file, since that's effectively what it's taking the place of.
__________________
Oracle's backup tutorial

"A lot of people say games are addictive. Well, they're addictive in the sense that anything you like doing you repeat endlessly. But no one would say, 'Mr Kasparov, you have a chess problem,' or 'Tiger Woods, you have a golf addiction.'" - Ian Livingstone, Creative Director, Eidos.

"A problem well stated is a problem half solved" - Charles Franklin Kettering
Reply With Quote
  #3  
Old August 18th, 2006, 07:24 PM
degsy's Avatar
degsy degsy is offline
Cyber Tech Help Moderator
 
Join Date: Jul 2001
Location: North-East, UK
Posts: 22,023
Blog Entries: 1
It's easy enough to set permissions for the file/folder to allow PHP to read the file but block the browser from reading it.

I would just suggest that you do some more learning then go for the database option as it will be much easier in the future.
__________________
Cheers,
Degs

Please post back with your results
CTH Terms of Use

CTH Subscriptions :: Adaware Guide :: HijackThis
Reply With Quote
Reply

Bookmarks

Topic 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
Forum Jump


All times are GMT +1. The time now is 01:34 PM.

[ RSS ]