Log-in
/* Simple Signup/Login script
Created on: Feburary 22, 2001
Copyright� Eric Gach! All Rights Reserved.
This Software is free and can be modified and redistributed
under the condition that the copyright and information above
stays intact and with the script.*/
#User Variables
$datafile="/home/username/data.txt";
#End User Variales
#If the call for the script is to log them in, DO IT!
if($action == "login"):
#This makes sure all fields are filled out.
if((!$username)or(!$password)){
#If there is one missing, send them to the error.
error_message("One or more required fields were left blank!", $username, $password);
}
#Open the datafile and login the user.
$file=file($datafile);
while(list(,$value)=each($file)){
list($fname,$femail,$furl,$fuser,$fpass,$blank)=split( "\|", $value);
if($username==$fuser && $password==$fpass){
echo "Log-in Success!
";
echo "";
$logink="1";
}
}
if($logink==""):
error_message("Login failed, bad username/password", $username, $password);
endif;
elseif($action=="change"):
#This makes sure all fields are filled out.
if((!$name)or(!$email)or(!$url)or(!$username)or(!$password)){
#If there is one missing, send them to the error.
error_message("One or more required fields were left blank! Please re-login.", $username, $password);
}
#Open the datafile and login the user.
$file=file($datafile);
while(list(,$value)=each($file)){
list($fname,$femail,$furl,$fuser,$fpass)=split( "\|", $value);
if($username==$fuser && $password==$fpass){
$oldword="$fname|$femail|$furl|$fuser|$fpass|";
$newword="$name|$email|$url|$username|$newpass|";
$fp = fopen($datafile, "r");
$data = fread($fp, filesize($datafile));
fclose($fp);
$newdata = str_replace($oldword, $newword, $data);
$fp = fopen($datafile,"w");
fwrite($fp,$newdata) or die ("error writing");
fclose($fp);
$succ = "1";
echo "Everything was changed successfully! Edit Again";
}
}
if(!$succ):
error_message("Login failed, bad username/password", $username, $password);
endif;
else:?>
Signup
/* Simple Signup/Login script
Created on: Feburary 22, 2001
Copyright� 123 Make Me! All Rights Reserved.
To get this script, goto http://123-makeme.com
This Software is free and can be modified and redistributed
under the condition that the copyright and information above
stays intact and with the script.*/
#User Variables
$datafile="/home2/BigE/data.txt";
#End User Variales
#If the action is to sign them up, do it!
if($action == "signup"):
#This makes sure all fields are filled out.
if((!$name)or(!$email)or(!$url)or(!$username)or(!$password)){
#If there is one missing, send them to the error.
error_message("One or more required fields were left blank!", $name, $email, $url, $username, $password);
}
#Open the datafile and make sure the user doesn't allready exist.
$file=file($datafile);
while(list(,$value)=each($file)){
list($fname,$femail,$furl,$fuser,$fpass,$blank)=split( "\|", $value);
if($username==$fuser){
#If the username is allready in user, error time.
error_message("Username is allready in use by someone else.", $name, $email, $url, $username, $password);
}
}
#If the username isn't in use, make it in use.
$fp=fopen($datafile,"a");
fwrite($fp,"$name|$email|$url|$username|$password|\n");
fclose($fp);
#Now we notify the person that they have signed up successfully.
?>
Success!
Your information was successfully added into our database. Thank you for signing up.
You may now login using the username: and password: at
the Login page.
#If the action is for anything else, show this.
else:?>