require_once '../includes/connector.php'; require_once '../includes/validates.php'; require_once '../includes/generaldb.php'; session_start(); function inputsvalidation() { $validateresult = array(); $validateresult['username'] = validateinput("username", "Username", array("required", 4)); $validateresult['secretword'] = validateinput("secretword", "Password", array("required", 8)); foreach ($validateresult as $key => $value) { //echo $value. $control; if ($value != 1) { $inputsvalid = false; $_SESSION['results']['message'] = "Username / Password is invalid"; header("Location: ../index.php"); } else { ${$key} = $_POST[$key]; } } if (validuser($username, $secretword)) { $_SESSION['userid'] = getuserid($username); header("Location: ../workspace.php"); } else { $_SESSION['results']['message'] = "Username / Password is invalid"; header("Location: ../index.php"); } } makeinputsafe(); inputsvalidation();
require_once '../includes/connector.php'; require_once '../includes/generaldb.php'; require_once '../includes/validates.php'; session_start(); function inputsvalidation() { $validateresult = array(); $validateresult['fullname'] = validateinput("fullname", "Full name", array("required", 4)); $validateresult['email'] = validateinput("email", "Email", array("required", 5, "email", "emailused")); $validateresult['username'] = validateinput("username", "Username", array("required", 4, "username")); $validateresult['password'] = validateinput("password", "Password", array("password", "match|repassword")); return $validateresult; } makeinputsafe(); $validates = inputsvalidation(); $allinputvalid = true; foreach ($validates as $key => $value) { //echo $value. $control; if ($value !== true) { $allinputvalid = false; $_SESSION['result'][$key] = array(0, $value); } else { $_SESSION['result'][$key] = array(1, $_POST[$key]); ${$key} = $_POST[$key]; } } if ($allinputvalid) { if ($stmt = $connection->prepare("INSERT INTO login (username,secretword,fullname,email) VALUES(?,?,?,?)")) { $stmt->bind_param('ssss', $username, md5($password), $fullname, $email); $stmt->execute();