Skip to content

Simple Portfolio with simple php mvc concept and PHPMailer library

Notifications You must be signed in to change notification settings

nsmle/simple-portfolio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple-Portfolio for full stack web developer

This simple portfolio automatically sends an email when a contact arrives from this portfolio page. and can also directly reply to incoming contacts

This simple portfolio uses the simple concept of mvc in php(Development of mvc concept learning in php from Mr. Sandhika Galih). Instead of using PHP's built-in mail() function. This simple portfolio uses the PHPmailer library to send email via the SMTP Protocol to a local or remote SMTP server.

Features

  • Authentication login and register with code verification using email
  • Contact the creator of the page via the email mechanism
  • Login multi user

Requirement

You need the PHPMailer library for this simple application. Otherwise, some errors will occur because the init.php and Mails\BaseMail file requires the PHPMailer library.

Installation

You can download Simple-Portfolio as a zip file. or clone this repo

git clone https://github.com/nsmle/simple-portfolio

To be able to use the PHPMailer library, you must install it. Read the PHPMailer Installation documentation

or add this line to your composer.json file:

"phpmailer/phpmailer": "^6.5"

or run

composer require phpmailer/phpmailer

Configuration

Database & Table

You can import the simple_portfolio.sql database into your database.

Config File

  • Rename the Example.Config.php file in app/Config/ to Config.php

  • Replace with your base url.

    // Base Url
    const BASEURL = 'YOUR BASE URL';
  • Replace with your database configuration.

    // Configuration Database
    const DB_HOST = 'YOUR DATABASE HOST';
    const DB_USER = 'YOUR DATABASE USER';
    const DB_PASS = 'YOUR DATABASE PASSWORD';
    const DB_NAME = 'YOUR DATABASE NAME';
  • For database error logs. Fill true if you want to enable error logging in the database and false to disable it.

    const DB_ERROR_LOG = true;

    This is related to the logs() function in app/Config/Constant.php

  • Email Configuration, This is related to Mail\BaseMail. You can see an example from PHPMailer here or more examples here

    • Replace with your smtp host. If you use gmail then fill it with smtp.gmail.com
    const MAIL_HOST = 'HOST YOUR MAIL';
    • Replace with your email and email password
    const MAIL_USERNAME = 'EMAIL YOUR MAIL';
    const MAIL_PASSWORD = 'PASSWORD YOUR MAIL';
    • Replace with your sender name and sender email
    const MAIL_FROMNAME  = 'YOUR SEENDER NAME';
    const MAIL_FROMEMAIL = 'YOUR SEENDER EMAIL';
    const MAIL_DEBUG = false;

    As a side note, if you are using gmail then you have to go to myaccount.google.com -> Log in & security -> Apps with account access, and change Allow less secure apps to ON (near the bottom page). Alternatively you can follow this direct link to these settings

  • Registration features

    If you allow other people to manage your site(http://yourbaseurl/admin) then give it a value of true and if you don't allow it then give it a value of false. Note, that before you set the value to false, make sure that you are registered and able to log in.

    const REGISTRATION_FEATURE = true;

    For the default user role. You can customize it with your users table in the role column

    const DEFAULT_ROLE_USER    = 'Admin';

Ajax Configuration

You have to change the ajax url in app/assets/js/main.js manually. in line

url: '[YOUR_BASE_URL]/home/contact',

Replace [YOUR_BASE_URL] with your base url, as an example :

// AJAX FOR SEND DATA
$.ajax({
  url: 'http://localhost:8000/home/contact',
  data: {name : name, email : email, phone : phone, message : message},
  method: 'post',
  success: function(data){
      document.getElementById('form-contact').innerHTML = data;
      console.log(data);
  },
  error: function(msg) {
      console.log(msg);
  }
});