|
-
Apr 22nd, 2007, 07:47 PM
#1
Thread Starter
Member
sorry it same proble php script
Hi everyone
I am bit stress I did for got to post the code last time I do apologise
I tried to create script to register user by storing their information in a text file and create directory for each one, no be noted I did crate the text file but nothing on it in but doesn't work without any error occurred I did checked the file sill empty despite storing some new user. Could any help please? With many thanks.
<html>
<title>Registration</title>
</head>
<body>
<fieldset>
<?php include "header.php"; ?>
<h3>Please type your details</h3>
<?php /*script to handle and display HTML form also register user by storing
their information in a text file and create a directory for them*/
//handle the form
if (isset ($_post['submit']))
{
$problem = false;//boolean to chack a state of problem or not, initialised to false
// no problem
// check username value of the form
if (empty($_post['username']))
{
$problem = true;
print '<p> Please enter your name</p>';
}
// check validation of entered password (confirmation)
if (empty($_post['password1']))
{
$problem = true;
print '<p> Please enter a password</p>';
}
// check validation of entered password (confirmation)
if ($_post['password1'] != $_post['password2'])
{
$problem = true;
print '<p> Your password not match confirmed password</p>';
}
// check if there weren't any problem
if(!$problem)
{
// open the file
if($fp = fopen('../users/users.txt', 'a+'))
{
//create the data to be written and close the file.
$dir = time () . rand(0,4596);
$data= $_post['username'] . "\t" . crypt($_post['password1']) . "\t"
.$dir . "\r\n";
//write data to and close the file.
fwrite($fp,$data);
fclose($fp);
// create the directory
mdir('../users/$dir');
// print a meessage
print '<p> You are registered</p>';
}
// forgot a field
else
{
print '<p> Please try again</p>';
}
}
else
{// could not write to the file
//print '<p><you could not be registered due to system error</p>';
}
}
// display the form
else
{
?>
<form action="new.php" method ="post">
Username <input type = "text" name ="username" size ="20"><br/>
Password <input type = "password" name ="password1" size ="20"><br/>
Confirm Password <input type = "password" name ="password2" size ="20"><br/>
<input type = "submit" name ="submit" value = "Register"><br/>
</fieldset>
</form>
<?php
}// end of submit if
?>
</body>
</html>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|