From ff406b07d008245937fac4df9fca4121e3c88fd9 Mon Sep 17 00:00:00 2001 From: SSUPII Date: Mon, 2 Mar 2020 19:07:46 +0100 Subject: [PATCH] Finished work on account registration --- acc/login.php | 23 +++++++++++++-- acc/registration.php | 67 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 acc/registration.php diff --git a/acc/login.php b/acc/login.php index 6c1f8ee..5431005 100644 --- a/acc/login.php +++ b/acc/login.php @@ -7,12 +7,16 @@ $strings[] = "en"; $strings[] = "Login"; $strings[] = "Register"; + $strings[] = "This username is already taken"; + $strings[] = "Registration completed"; break; } case "it":{ $strings[] = "it"; $strings[] = "Accesso"; $strings[] = "Registra"; + $strings[] = "Questo username è stato già usato"; + $strings[] = "Registrazione completata"; break; } default:{ @@ -37,7 +41,7 @@ Web Musei - Italiano English + Italiano English
Web Musei
@@ -47,8 +51,22 @@
+

Username
Password
@@ -85,6 +103,7 @@ function checkps(){ }else{ document.log.action = "./sessionstart.php?lang="+lang; } + submited = "undefined"; }
diff --git a/acc/registration.php b/acc/registration.php new file mode 100644 index 0000000..5e2729b --- /dev/null +++ b/acc/registration.php @@ -0,0 +1,67 @@ + + + + + + + Web Musei + + + Creating... + 0){ + header("Location: http://127.0.0.1/webmuseoscuola/acc/login.php?lang=$strings[0]&err=1"); + }else{ + $length = 24; + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $charactersLength = strlen($characters); + do{ + $randomString = ''; + for ($i = 0; $i < $length; $i++) { + $randomString .= $characters[rand(0, $charactersLength - 1)]; + } + }while(mysqli_num_rows(mysqli_query($connection,"SELECT id FROM users WHERE id = \"$randomString\"")) > 0); + $sql = "INSERT INTO users VALUES (\"$randomString\", \"$_POST[user]\", \"".sha1($_POST["pass"])."\", 0)"; + $result = mysqli_query($connection,$sql); + if($result != FALSE){ + header("Location: http://127.0.0.1/webmuseoscuola/acc/login.php?lang=$strings[0]&err=-1"); + } + } + }else { + header("Location: http://127.0.0.1/webmuseoscuola/acc/login.php?lang=$strings[0]"); + } + }else { + header("Location: http://127.0.0.1/webmuseoscuola/acc/login.php?lang=$strings[0]"); + } + + ?> + +