-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup_action.php
26 lines (25 loc) · 954 Bytes
/
signup_action.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
<?php
require_once("static/includes/sessions.php");
require_once("static/includes/functions.php");
require_once("static/includes/dbsetup.php");
if(isset($_POST["submit"])){
$username1 = mysqli_real_escape_string($conn,$_POST["username_"]);
$password = mysqli_real_escape_string($conn,$_POST["new_password_"]);
//$confirm_password = mysqli_real_escape_string($conn,$_POST["confirm_password_"]);
$password = sha1($password); //ENCRYPTION
$query_check = "SELECT * FROM admins WHERE username = '".$username1."'";
$temp = mysqli_query($conn,$query_check);
if(mysqli_num_rows($temp) != 0){
redirect_to('signup.php');
} // TESTED - OK
$query = "INSERT INTO admins (username,password) VALUES ('{$username1}','{$password}')";
$result = mysqli_query($conn,$query);
if($result){
redirect_to('login.php');
} else{
redirect_to('signup.php');
}
} else{
redirect_to('signup.php');
}
?>