<?php session_start(); require_once 'conn.php'; require_once '../libs/Bcrypt.php'; $bcrypt = new Bcrypt(15); $action = $_POST['action']; switch ($action) { case 'sign_up': $email = $_POST['email']; $password = $_POST['pword']; $salt = $bcrypt->getSalt(); $hash = $bcrypt->hash($password, $salt); if ($query = $db->prepare("INSERT INTO tbl_users SET email = ?, hashed_password = ?, salt = ?")) { $query->bind_param("sss", $email, $hash, $salt); $query->execute(); $uid = $query->insert_id; //create default settings for new user $select_networks = $db->query("SELECT network FROM tbl_networks"); if ($select_networks->num_rows > 0) { while ($row = $select_networks->fetch_object()) { $network = $row->network; $db->query("INSERT INTO tbl_settings SET network = '{$network}', uid = '{$uid}', status = 0"); } } echo $uid; } break; case 'login': $email = $db->real_escape_string($_POST['email']); $password = $db->real_escape_string($_POST['pword']);