Re: sign up script
| From: | Boris.C | Date: | Tue, 31 Oct 2000 11:28:02 +0000 |
| Subject: | Re: sign up script | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-22915@lists.php.net to get a copy of this message | ||
This is the Code for doing the Same with a text file instead of the
Databank, hope it helps.
<?
$userfile = "usrdata/" . $name . ".txt";
$errorcodeA=0; // $errorcodeA == 1: Undefined Error
$errorcodeB=0; // $errorcodeB == 1: Username already exists
$errorcodeC=0; // $errorcodeC == 1: No Username entered
$errorcodeD=0; // $errorcodeD == 1: No Password entered
$errorcodeE=0; // $errorcodeE == 1: No Email entered
if(strlen($name) == 0){$errorcodeA=1; $errorcodeC=1;}
if(strlen($password) == 0){$errorcodeA=1; $errorcodeD=1;}
if(strpos($email, "@") == false){$errorcodeA=1; $errorcodeE=1;}
if (file_exists ($userfile)){$errorcodeA=1; $errorcodeB=1; }
if ($errorcodeA == 0)
{
$filename = "usrdata/users.txt";
$fp = fopen($filename, "r+");
do {
$buffer = fgets($fp, 4096);
fgets($fp, 4096);
$pass = fgets($fp, 4096);
$buffer = rtrim($buffer);
$buffer = ltrim($buffer);
}while((!feof ($fp)) && (!$buffer == $name));
$pass = rtrim($pass);
$pass = ltrim($pass);
$buffer = rtrim($buffer);
$buffer = ltrim($buffer);
}
if ($errorcodeA == 0)
{
$fp = fopen($filename, "r+");
while (!feof ($fp)){fgets($fp, 4096);}
fputs ($fp, " " . $name . "\n");
fputs ($fp, " " . $email . "|" . $newsletter . "\n");
fputs ($fp, " " . $password . "\n");
fclose($fp);
$fp = fopen($userfile, "w+");
fclose($fp);
}
?>
<? if ($errorcodeA == 0): ?>
Erfolgreich Eingetragen
<? endif; ?>
<? if ($errorcodeA == 1): ?>
<b>Fehler:</b><br>
<? endif; ?>
<? if ($errorcodeB == 1): ?>
<li>Username already exists
<? endif; ?>
<? if ($errorcodeC == 1): ?>
<li>No name entered<br>
<? endif; ?>
<? if ($errorcodeD == 1): ?>
<li>Password not allowed<br>
<? endif; ?>
<? if ($errorcodeE == 1): ?>
<li>Email not correct.<br>
<? endif; ?>