I was trying to use this login system that didn't use databases but when I tried to register with it I kept getting an error message.
here is the error message:
Parse error: syntax error, unexpected '}' in /home/sublimis/public_html/jay/login script/register.php on line 17
the login system consists of 4 files: login.html, login.php, registration.html, registration.php, and users.txt
I'll put the registration file first since that's where the error is:
<?php
if (isset ($_POST['submit'])) {
$problem = FALSE;
if (empty ($_POST['username'])) {
$problem = TRUE;
print 'please enter a username!';
}
if (empty ($_POST['password'])) {
$problem = TRUE;
print 'Please enter a password';
}
if (empty ($_POST['password2'])) {
$problem = TRUE;
print 'Your password did not match your confirmed password';
}
if ( !$problem )
if ($fp = fopen ( 'users.txt', 'ab' )) { //Open the file!
$dir = time() . rand 90, 4596;
$data = $_POST['username'] . "\t" . crypt($_POST['password'] . "\t" . $dir . "\r\n";
// Write data and close file!
fwrie ( $fp, $data );
fclose ( $fp );
mkdir ( $dir )
print 'You are now registered!';
} else {
print 'You could not be regiseter due to an error';
}
} else {
print 'Please try again!';
}
} else {
?>
here's the registration.html
<form action="register.php" method="post">
Username: <input type="text" name="username">
<br /><br />
Password: <input type="password" name="password">
<br /><br />
Confirm Password: <input type="password" name="password2">
<br /><br />
<input type="submit" name="submit" value="register">
</form>
here is the login.php
<?php
if (isset ($_POST['submit'])) {
$loggedin = FALSE;
$fp = fopen ( 'users.txt', 'rb' );
while ( $line = fgetcsv ($fp, 100, "\t")) {
if ( ($line[0] == $_POST['username']) AND ($line[1] == crypt ($_POST['password'], l$line[1]) ) ) {
$loggedin = TRUE;
break;
}
}
if ($loggedin) {
print 'You are now logged in!';
} else {
print 'The username and password did not match!';
?>
and here's the login.html
Username: <input type="text" name="username">
<br /><br />
Password: <input type="password" name="password">
<br /><br />
<input type="submit" name="submit" value="log in!">
and the user.txt is just a text file with all the permissions
if you find any other problems with this, just let me know... I know pretty much nothing about php (I'm more of an xhtml, css junkie XD)