Skip to content

Instantly share code, notes, and snippets.

Avatar

Derdus derduskenga

View GitHub Profile
View goToMainMenufunction.php
<?php
public function goToMainMenu($text){
$explodedText = explode("*",$text);
while(array_search(Util::$GO_TO_MAIN_MENU, $explodedText) != false){
$firstIndex = array_search(Util::$GO_TO_MAIN_MENU, $explodedText);
$explodedText = array_slice($explodedText, $firstIndex + 1);
}
return join("*",$explodedText);
}
View sms.php
<?php
require 'vendor/autoload.php';
use AfricasTalking\SDK\AfricasTalking;
include_once 'util.php';
class Sms {
protected $AT;
function __construct()
{
$this->AT = new AfricasTalking(Util::$API_USERNAME, Util::$API_KEY);
}
View registerMenufunction.php
public function registerMenu($textArray, $phoneNumber){
//building menu for user registration
$level = count($textArray);
if($level == 1){
echo "CON Please enter your full name:";
} else if($level == 2){
echo "CON Please enter set you PIN:";
}else if($level == 3){
echo "CON Please re-enter your PIN:";
}else if($level == 4){
View menusurvey.sql
-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jul 28, 2021 at 02:05 PM
-- Server version: 10.4.13-MariaDB
-- PHP Version: 7.4.7
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
View user.php
<?php
include_once 'util.php';
include_once 'db.php';
class User {
protected $phoneNumber;
protected $name;
public function allPhoneNumbers($pdo){
//returns an array of phone numbers
try{
$stmt = $pdo->prepare("SELECT phone_number FROM user");
View survey.php
<?php
include_once 'util.php';
include_once 'db.php';
include_once 'user.php';
include_once 'sms.php';
class Survey {
protected $title;
protected $description;
public function addUserToSurvey ($pdo, $users, $surveyId, $level,$invitationsStatus){
//$users is an indexed array of phone numbers.