Skip to content

Instantly share code, notes, and snippets.

View rintoug's full-sized avatar

Rinto George rintoug

View GitHub Profile
@rintoug
rintoug / model.php
Last active June 4, 2017 07:50
How to do Pagination in CodeIgniter
<?php
class Country_model extends CI_Model {
public function __construct()
{
parent::__construct();
}
public function total_rows()
{
@rintoug
rintoug / mail.php
Last active May 28, 2017 10:25
Send an Email using SMTP Server and PHPMailer
<?php
include "vendor/autoload.php";
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
@rintoug
rintoug / delete.php
Created May 28, 2017 07:52
Connect and Handle Files in FTP Server using PHP
<?php
// FTP server details
$ftpHost = 'ftp.host.com';
$ftpUsername = 'tutsplanet';
$ftpPassword = 'xxxxxxxx';
// open an FTP connection
$connId = ftp_connect($ftpHost) or die("Couldn't connect to $ftpHost");
// login to FTP
@rintoug
rintoug / download.php
Created May 28, 2017 07:50
Connect and Handle Files in FTP Server using PHP
<?php
// FTP server details
$ftpHost = 'ftp.host.com';
$ftpUsername = 'tutsplanet';
$ftpPassword = 'xxxxxxxxxx';
// open an FTP connection
$connId = ftp_connect($ftpHost) or die("Couldn't connect to $ftpHost");
// login to FTP
@rintoug
rintoug / upload.php
Created May 28, 2017 07:48
Connect and Handle Files in FTP Server using PHP
<?php
// FTP server details
$ftpHost = 'ftp.host.com';
$ftpUsername = 'tutsplanet';
$ftpPassword = 'xxxxxxx';
// open an FTP connection
$connId = ftp_connect($ftpHost) or die("Couldn't connect to $ftpHost");
// login to FTP
@rintoug
rintoug / connect.php
Created May 28, 2017 07:43
Connect and Handle Files in FTP Server using PHP
<?php
// FTP server details
$ftpHost = 'ftp.host.com';
$ftpUsername = 'tutsplanet';
$ftpPassword = 'xxxxxxxx';
// open an FTP connection
$connId = ftp_connect($ftpHost) or die("Couldn't connect to $ftpHost");
// login to FTP
@rintoug
rintoug / empty.php
Created May 25, 2017 11:20
Simple PHP Shopping Cart
<?php
//Empty All
if($action=='emptyall') {
$_SESSION['products'] =array();
header("Location:shopping-cart.php");
}
//Empty one by one
if($action=='empty') {
$sku = $_GET['sku'];
@rintoug
rintoug / addtocart.php
Created May 25, 2017 11:19
Simple PHP Shopping Cart
<?php
//Add to cart
if($action=='addcart' && $_SERVER['REQUEST_METHOD']=='POST') {
//Finding the product by code
$query = "SELECT * FROM products WHERE sku=:sku";
$stmt = $conn->prepare($query);
$stmt->bindParam('sku', $_POST['sku']);
$stmt->execute();
$product = $stmt->fetch();
@rintoug
rintoug / html.php
Created May 25, 2017 11:17
Simple PHP Shopping Cart
<div class="row">
<div class="container" style="width:600px;">
<?php foreach($products as $product):?>
<div class="col-md-4">
<div class="thumbnail"> <img src="<?php print $product['image']?>" alt="Lights">
<div class="caption">
<p style="text-align:center;"><?php print $product['name']?></p>
<p style="text-align:center;color:#04B745;"><b>$<?php print $product['price']?></b></p>
<form method="post" action="shopping-cart.php?action=addcart">
<p style="text-align:center;color:#04B745;">
@rintoug
rintoug / insert.php
Created May 22, 2017 09:35
PHP User Registration Form
<?php
try {
$conn = new PDO("mysql:host=localhost;dbname=tutsplanet", 'root', '');
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$password = password_hash($_POST['password'], PASSWORD_BCRYPT); //hashing password
$query = "INSERT INTO `customers` (`username`, `firstname`,`lastname`, `email`, `password`, `gender`)
VALUES (:username, :firstname,:lastname, :email, :password, :gender)";
$stmt = $conn->prepare($query);