forked from DomBottom/module2-group-475438-474014
-
Notifications
You must be signed in to change notification settings - Fork 0
/
regis.php
44 lines (40 loc) · 1.14 KB
/
regis.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!DOCTYPE html>
<html>
<head>
<title> create</title>
</head>
<body>
<?php
// add the new username to the users.txt
$Aname = $_GET['new'];
$h = fopen("/srv/usersName/users.txt", "r");
$log = 0;
// create user's folder to store files
mkdir("/srv/uploads/".$Aname,0777);
$f = fopen('users.txt','w');
fwrite($f, "%s\n", htmlentities($Aname));
// check if username already exist if yes to the already exist page
while( !feof($h) ){
if(trim(fgets($h)) == $Aname){
$log = 1;
}
}
if($log == 1){
echo "The username has alredy exist!";
}
// if new username created successfuly, return to the login page
else{
$path = "/srv/uploads/$Aname";
mkdir($path, 0777, true);
$f = fopen('/srv/usersName/users.txt','a+');
fputs($f,$Aname."\n");
}
fclose($h);
fclose($f);
?>
<form action ="login.html" method = "GET">
<br><br>
<input type="submit" value="Go back to Login" />
</form>
</body>
</html>