function admin_test_main() { // Create user echo '<br><h3>Creating User.</h3><br>'; $user_1 = user_1(); user\add_user($user_1); echo '<br><h3>User created!</h3><br>'; // Verify $user_1_db = user\authenticate_user($user_1['email_address'], $user_1['password']); $user_1_id = $user_1_db['id']; echo "<br><h3>User ID: {$user_1_id}</h3><br>"; // Update user echo "<br><h3>Updating User.</h3><br>"; $user_1_db['email_address'] = '*****@*****.**'; $user_1_db['last_name'] = 'Two'; update_user($user_1_db); echo "<br><h3>User Updated!</h3><br>"; // Verify $user_2_db = user\authenticate_user('*****@*****.**', $user_1['password']); $new_last_name = $user_2_db['last_name']; echo "<br><h3>New User Last Name: {$user_2_db}"; // Delete user echo "<br><h3>Deleting User.</h3><br>"; delete_user(array("user_id" => $user_1_id)); echo "<br><h3>User deleted!</h3><br>"; }
function login_main() { global $status, $msg; if (empty($_POST)) { $status = 'Error!'; $msg = 'Login information not specified.'; return; } if (empty($_POST['login-email']) or empty($_POST['login-password'])) { $status = 'Error!'; $msg = 'Login information not specified.'; return; } $email_address = $_POST['login-email']; $password = $_POST['login-password']; if (user\authenticate_user($email_address, $password)) { $status = 'Logged In!'; $msg = 'You have successfully logged in to Easy Ride!'; } else { $status = 'Invalid Credentials!'; $msg = 'You have specified an invalid combination of email address and password.'; } }
$missing_fields = array(); foreach ($required as $post_key => $db_key) { if (empty($_POST[$post_key])) { $missing_fields[] = $post_key; } else { $user_data[$db_key] = $_POST[$post_key]; } } // Copy over non-required fields $user_data['drivers_license_id'] = $_POST['register-drivers-license-id']; if ($missing_fields) { $status = 'Error!'; $msg = 'Missing fields: ' . implode(', ', $missing_fields); } else { user\add_user($user_data); user\authenticate_user($user_data['email_address'], $user_data['password']); $status = 'Success!'; $msg = 'You have successfully registered for Easy Ride!'; } } include 'templates/head.php'; ?> <div class="well ds-component ds-hover container-narrow" data-componentid="well1"> <div class="ds-component ds-hover" data-componentid="content2"> <?php functions\html_respond($status, $msg); ?> </div> </div> <?php include 'templates/footer.php';