Hi all can anyone please help me with this problem i have in the code below :
The detail does not store in the specified file I don't know why? I did create a users folder out side web server root and the users file inside the user folder.
PHP Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<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 password value of the form
if (empty($_post['password']))
{
$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', 'ab'))
{
//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>




Reply With Quote