diff --git a/.github/workflows/symfony.yml b/.github/workflows/symfony.yml new file mode 100644 index 0000000..17912cb --- /dev/null +++ b/.github/workflows/symfony.yml @@ -0,0 +1,47 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Symfony + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +permissions: + contents: read + +jobs: + symfony-tests: + runs-on: ubuntu-latest + steps: + # To automatically get bug fixes and new Php versions for shivammathur/setup-php, + # change this to (see https://github.com/shivammathur/setup-php#bookmark-versioning): + # uses: shivammathur/setup-php@v2 + - uses: shivammathur/setup-php@2cb9b829437ee246e9b3cac53555a39208ca6d28 + with: + php-version: '8.0' + - uses: actions/checkout@v3 + - name: Copy .env.test.local + run: php -r "file_exists('.env.test.local') || copy('.env.test', '.env.test.local');" + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + - name: Install Dependencies + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + - name: Create Database + run: | + mkdir -p data + touch data/database.sqlite + - name: Execute tests (Unit and Feature tests) via PHPUnit + env: + DATABASE_URL: sqlite:///%kernel.project_dir%/data/database.sqlite + run: vendor/bin/phpunit diff --git a/dataApp/UDEMY.php b/dataApp/UDEMY.php new file mode 100644 index 0000000..ef4ba9b --- /dev/null +++ b/dataApp/UDEMY.php @@ -0,0 +1 @@ +dataApp : https://www.udemy.com/course/advanced-php-web-development-w-mysql-github-bootstrap-4/learn/lecture/15808034#overview diff --git a/dataApp/css/site.css b/dataApp/css/site.css new file mode 100644 index 0000000..e69de29 diff --git a/dataApp/db/conn.php b/dataApp/db/conn.php new file mode 100644 index 0000000..1df3750 --- /dev/null +++ b/dataApp/db/conn.php @@ -0,0 +1,32 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + } catch(PDOException $e) { + throw new PDOException($e->getMessage()); + } + + require_once 'crud.php'; + require_once 'user.php'; + $crud = new crud($pdo); + $user = new user($pdo); + + $user->insertUser("admin","password"); +?> \ No newline at end of file diff --git a/dataApp/db/crud.php b/dataApp/db/crud.php new file mode 100644 index 0000000..d5d70a5 --- /dev/null +++ b/dataApp/db/crud.php @@ -0,0 +1,131 @@ +db = $conn; + } + + // function to insert a new record into the attendee database + public function insertAttendees($fname, $lname, $dob, $email,$contact,$specialty,$avatar_path){ + try { + // define sql statement to be executed + $sql = "INSERT INTO attendee (firstname,lastname,dateofbirth,emailaddress,contactnumber,specialty_id,avatar_path) VALUES (:fname,:lname,:dob,:email,:contact,:specialty,:avatar_path)"; + //prepare the sql statement for execution + $stmt = $this->db->prepare($sql); + // bind all placeholders to the actual values + $stmt->bindparam(':fname',$fname); + $stmt->bindparam(':lname',$lname); + $stmt->bindparam(':dob',$dob); + $stmt->bindparam(':email',$email); + $stmt->bindparam(':contact',$contact); + $stmt->bindparam(':specialty',$specialty); + $stmt->bindparam(':avatar_path',$avatar_path); + + // execute statement + $stmt->execute(); + return true; + + } catch (PDOException $e) { + echo $e->getMessage(); + return false; + } + } + + public function editAttendee($id,$fname, $lname, $dob, $email,$contact,$specialty){ + try{ + $sql = "UPDATE `attendee` SET `firstname`=:fname,`lastname`=:lname,`dateofbirth`=:dob,`emailaddress`=:email,`contactnumber`=:contact,`specialty_id`=:specialty WHERE attendee_id = :id "; + $stmt = $this->db->prepare($sql); + // bind all placeholders to the actual values + $stmt->bindparam(':id',$id); + $stmt->bindparam(':fname',$fname); + $stmt->bindparam(':lname',$lname); + $stmt->bindparam(':dob',$dob); + $stmt->bindparam(':email',$email); + $stmt->bindparam(':contact',$contact); + $stmt->bindparam(':specialty',$specialty); + + // execute statement + $stmt->execute(); + return true; + }catch (PDOException $e) { + echo $e->getMessage(); + return false; + } + + } + + public function getAttendees(){ + try{ + $sql = "SELECT * FROM `attendee` a inner join specialties s on a.specialty_id = s.specialty_id"; + $result = $this->db->query($sql); + return $result; + }catch (PDOException $e) { + echo $e->getMessage(); + return false; + } + + } + + public function getAttendeeDetails($id){ + try{ + $sql = "select * from attendee a inner join specialties s on a.specialty_id = s.specialty_id + where attendee_id = :id"; + $stmt = $this->db->prepare($sql); + $stmt->bindparam(':id', $id); + $stmt->execute(); + $result = $stmt->fetch(); + return $result; + }catch (PDOException $e) { + echo $e->getMessage(); + return false; + } + } + + public function deleteAttendee($id){ + try{ + $sql = "delete from attendee where attendee_id = :id"; + $stmt = $this->db->prepare($sql); + $stmt->bindparam(':id', $id); + $stmt->execute(); + return true; + }catch (PDOException $e) { + echo $e->getMessage(); + return false; + } + } + + public function getSpecialties(){ + try{ + $sql = "SELECT * FROM `specialties`"; + $result = $this->db->query($sql); + return $result; + }catch (PDOException $e) { + echo $e->getMessage(); + return false; + } + + } + + public function getSpecialtyById($id){ + try{ + $sql = "SELECT * FROM `specialties` where specialty_id = :id"; + $stmt = $this->db->prepare($sql); + $stmt->bindparam(':id', $id); + $stmt->execute(); + $result = $stmt->fetch(); + return $result; + }catch (PDOException $e) { + echo $e->getMessage(); + return false; + } + + } + + + + + } +?> \ No newline at end of file diff --git a/dataApp/db/user.php b/dataApp/db/user.php new file mode 100644 index 0000000..534e354 --- /dev/null +++ b/dataApp/db/user.php @@ -0,0 +1,80 @@ +db = $conn; + } + + public function insertUser($username,$password){ + try { + $result = $this->getUserbyUsername($username); + if($result['num'] > 0){ + return false; + } else{ + $new_password = md5($password.$username); + // define sql statement to be executed + $sql = "INSERT INTO users (username,password) VALUES (:username,:password)"; + //prepare the sql statement for execution + $stmt = $this->db->prepare($sql); + // bind all placeholders to the actual values + $stmt->bindparam(':username',$username); + $stmt->bindparam(':password',$new_password); + + // execute statement + $stmt->execute(); + return true; + } + + + } catch (PDOException $e) { + echo $e->getMessage(); + return false; + } + } + + public function getUser($username,$password){ + try{ + $sql = "select * from users where username = :username AND password = :password "; + $stmt = $this->db->prepare($sql); + $stmt->bindparam(':username', $username); + $stmt->bindparam(':password', $password); + $stmt->execute(); + $result = $stmt->fetch(); + return $result; + }catch (PDOException $e) { + echo $e->getMessage(); + return false; + } + } + + public function getUserbyUsername($username){ + try{ + $sql = "select count(*) as num from users where username = :username"; + $stmt = $this->db->prepare($sql); + $stmt->bindparam(':username',$username); + + $stmt->execute(); + $result = $stmt->fetch(); + return $result; + }catch (PDOException $e) { + echo $e->getMessage(); + return false; + } + } + + public function getUsers(){ + try{ + $sql = "SELECT * FROM users"; + $result = $this->db->query($sql); + return $result; + }catch(PDOException $e){ + echo $e->getMessage(); + return false; + } + } + } +?> \ No newline at end of file diff --git a/dataApp/includes/auth_check.php b/dataApp/includes/auth_check.php new file mode 100644 index 0000000..6e96b32 --- /dev/null +++ b/dataApp/includes/auth_check.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/dataApp/includes/errormessage.php b/dataApp/includes/errormessage.php new file mode 100644 index 0000000..8db225f --- /dev/null +++ b/dataApp/includes/errormessage.php @@ -0,0 +1,3 @@ +