<?php namespace MotaRaido\SignUp; use \MotaRaido\Core\View; use \MotaRaido\Core\Route; if (!defined('MOTAFW')) { echo 'This file can only be called via the main index.php file, and not directly'; exit(); } Route::add('/signup', function() { $view = new View(); $view->assign('title', 'Sign Up'); $view->assign('style', CSS . "style.css"); $view->assign('profileStyle', CSS . "profile.css"); $view->assign('script', JS . "signup.js?time=" . date("H:i:s")); $view->render(__DIR__ . '/SignUp.view.php', false); }); Route::add('/signup/validation', function() use ($query) { // header('Location: /signup'); $query->transaction(function() use ($query) { $username = $_GET['username']; if ($_GET['password'] === $_GET['confirm-password']) $password = $_GET['password']; else $password = null; $email = $_GET['email']; $fullname = $_GET['your-name']; $phone = $_GET['phone-number']; $isdriver = isset($_GET['driver']) ? 1 : 0; $ratingArray['username'] = $_GET['username']; $ratingArray['rating'] = 0; $ratingArray['votes'] = 0; $ratingArray['numrat'] = 0; $datauser = $query->select('user', ['username' => $username]); $preferredlocArray['username'] = $_GET['username']; if ($password != null && count($datauser) == 0) { $query->insert('user', ['username' => $username, 'password'=> $password, 'email' => $email, 'fullname' => $fullname, 'phone' => $phone, 'isdriver' => $isdriver]); $query->insert('rating', $ratingArray); $query->insert('preferredloc', $preferredlocArray); header('Location: /profile/' . $username); } }); }); Route::add('/validation', function() use ($query) { if(isset($_GET['email'])) { $email = $_GET['email']; $emailData = $query->select('user', ['email' => $email]); $found = count($emailData) !== 0; } else if(isset($_GET['username'])) { $username = $_GET['username']; $usrData = $query->select('user', ['username' => $username]); $found = count($usrData) !== 0; } if($found) { print_r('Failed'); } else { print_r('OK'); } });