Skip to content
Snippets Groups Projects
Forked from IF3110 / TugasBesar1_2017
26 commits ahead of the upstream repository.
RegisterController.php 805 B
<?php
/**
 * Created by PhpStorm.
 * User: iqbal
 * Date: 05/10/17
 * Time: 16:43
 */

    include_once "Controller.php";
    include_once "../model/User.php";

    $hashedPassword = md5($_POST['password']);

    $newUser = array(
        "id" => 0,
        "name" => $_POST['name'],
        "username" => $_POST['username'],
        "email" => $_POST['email'],
        "password" => $hashedPassword,
        "phone" => $_POST['phone'],
        "photo" => "http://www.simian-risk.com/wp-content/themes/custom/images/empty-profile.png",
        "is_driver" => 0
    );

    if (isset($_POST['is_driver'])) {
        $newUser['is_driver'] = 1;
    }

    $pdo = DB::getInstance();
    User::InsertUser($newUser, $pdo);
    //header untuk redirect
    echo "<script> alert('Registrasi berhasil.');</script>";