This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function index() | |
{ | |
$this->loadModel('Products'); | |
$this->viewBuilder()->setLayout('new'); | |
$ip = $this->request->clientIp(); | |
$carts = $this->Carts->find('all') | |
->where(['Carts.ip' => $ip]) | |
->contain(['Products']); | |
$this->set(compact('carts')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ($this->request->is('post')) { | |
// Start | |
if(!empty($this->request->data['image']['name'])) | |
{ | |
$fileName = $this->request->data['image']['name']; | |
$uploadPath = 'img/uploads/products/'; | |
$uploadFile = $uploadPath . $fileName; | |
if(move_uploaded_file($this->request->data['image']['tmp_name'], $uploadFile)) | |
{ | |
// $this->request->data['image'] = $fileName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include 'include/connection.php'; | |
$conn = db(); | |
if(isset($_POST["username"]) && strlen($_POST["username"]) >= 3 && !empty($_POST["username"]) ) | |
{ | |
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') { | |
die(); | |
} | |
$username = filter_var($_POST["username"], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW|FILTER_FLAG_STRIP_HIGH); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// filename: include/class.user.php | |
include 'connection.php'; | |
class User{ | |
public $db; | |
/*** for registration process ***/ | |
public function reg_user($name,$username,$password,$email){ | |
$conn = db(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// filename include/connection.php | |
define('DB_SERVER', 'localhost'); | |
define('DB_USERNAME', 'root'); | |
define('DB_PASSWORD', ''); | |
define('DB_DATABASE', 'oop'); | |
function db () { | |
static $conn; | |
if ($conn===NULL){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// filename: include/login.php | |
session_start(); | |
include 'class.user.php'; | |
if (isset($_REQUEST['login'])) { | |
$user = new User(); | |
extract($_REQUEST); | |
$login = $user->check_login($emailusername, $password); | |
if ($login) { | |
// Registration Success |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// filename: include/register.php | |
session_start(); | |
//n | |
include 'class.user.php'; | |
$user = new User(); // Checking for user logged in or not | |
if (isset($_REQUEST['register'])){ | |
extract($_REQUEST); | |
$register = $user->reg_user($fullname, $uname,$upass, $uemail); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
include 'include/class.user.php'; | |
$user = new User(); | |
$uid = $_SESSION['uid']; | |
if (!$user->get_session()){ | |
header("location:login.php"); | |
exit(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php session_start(); ?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Registration</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<script type="text/javascript"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Login</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> |
NewerOlder