$_SESSION['error'] .= $errEmail; if (preg_match("/[a-zA-Z0-9!@#\$%^&*]/", $_POST['password']) == 0) { $errPass = '******'; $valid++; } $_SESSION['error'] .= $errPass; if ($_POST['confirm'] != $_POST['password']) { $errConfirm = '<p class="errText">Your passwords don\'t match!</p>'; $valid++; } $_SESSION['error'] .= $errConfirm; /////////////////////////////// // THIS ADDS A NEW USER // /////////////////////////////// if ($valid == 0) { insert_new_user($_POST['fname'], $_POST['lname'], $_POST['email'], $_POST['password']); $_SESSION['error'] .= '<p class="registered">Thank you for registering! You may now log in.</p>'; } header('location: ./index.php'); } ///////////////////////// // LOGIN CHECK // ///////////////////////// if (isset($_POST['action']) && $_POST['action'] == 'login') { $query = 'SELECT * FROM users WHERE email = "' . $_POST['email'] . '";'; $user = fetch_record($query); if ($user == null) { $errLogin = "******"; $_SESSION['error'] .= $errLogin; header('location: ./index.php'); } else {
function write_into_database($users, $userid) { foreach ($users as $user) { $ret = insert_new_user($user, $userid); // if (is_problem_exist($problem)) // { // $ret = update_old_problem($problem); // } // else // { // $ret = insert_new_problem($problem); // } if ($ret != SUCCESS) { return $ret; } } return SUCCESS; }