Ejemplo n.º 1
0
<!--TODO user validation-->
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Update Redirect</title>
    <link rel="stylesheet" href="../src/stylesheet/redirect.css" media="screen" title="no title" charset="utf-8">
  </head>
  <body>
  <?php 
//TODO remember me
include '../config/config.php';
include MODEL_PATH . "customer.php";
include CONFIG_PATH . 'flash.php';
$customer = new Customer_Model();
if (isset($_POST['login_submit'])) {
    $username = htmlspecialchars($_POST['login_username']);
    $password = htmlspecialchars($_POST['login_password']);
    if ($customer->validate_login($username, $password)) {
        flash("notice", "Succesfuly login as " . $username);
        echo '<div class="notice_redirect">Login Successfull, the page will redirect</div>';
        header("Refresh:3;url=/shop/index.php");
    } else {
        echo '<div class="notice_redirect">Login failed, the page will redirect</div>';
        flash("notice", "Login failed", "error");
        header("Refresh:3;url=/shop/index.php");
    }
}
?>
  </body>
</html>
Ejemplo n.º 2
0
 /**
  * Checkout 
  * @return void
  */
 public function checkout()
 {
     // Check user permission
     if (user::is_logged()) {
         if ($this->cart->count_cart() != 0) {
             $customer = new Customer_Model();
             if ($customer->has_info()) {
                 // check if customer profile is set (at least personal informations)
                 // Settings
                 $this->set_title(Kohana::lang('eshop.checkout'));
                 $this->add_breadcrumb(Kohana::lang('eshop.checkout'), '/cart/checkout');
                 // Other needed models, and data
                 $shipping = new Shipping_Model();
                 $payment = new Payment_Model();
                 $order = new Order_Model();
                 // Fetching values
                 $cart = $this->cart->get_cart();
                 $total = $this->cart->get_total();
                 $shipping_methods = $shipping->get_all();
                 $payment_methods = $payment->get_all();
                 $profile = $customer->get_profile(user::user_id());
                 // Default values
                 $form = array('delivery_name' => $profile['name'], 'delivery_street' => $profile['customer_street'], 'delivery_city' => $profile['customer_city'], 'delivery_postal_code' => $profile['customer_postal_code'], 'shipping' => $shipping->get_default(), 'payment' => $payment->get_default());
                 $errors = array();
                 // Validation
                 if ($_POST) {
                     $post = new Validation($_POST);
                     // Some filters
                     $post->pre_filter('trim', TRUE);
                     // Rules
                     $post->add_rules('delivery_name', 'required', 'length[0,255]');
                     $post->add_rules('delivery_street', 'required');
                     $post->add_rules('delivery_city', 'required');
                     $post->add_rules('delivery_postal_code', 'required', 'length[0,255]');
                     $post->add_rules('shipping', 'required');
                     $post->add_callbacks('shipping', array($shipping, '_exists'));
                     $post->add_rules('payment', 'required');
                     $post->add_callbacks('payment', array($payment, '_exists'));
                     if ($post->validate()) {
                         // Everything seems to be ok, insert to db
                         $id = $order->add_data($post, $profile, $cart);
                         $this->cart->empty_cart();
                         // Now payment
                         url::redirect('/cart/payment/' . $id);
                     } else {
                         // Repopulate form with error and original values
                         $form = arr::overwrite($form, $post->as_array());
                         $errors = $post->errors('cart_checkout_errors');
                     }
                 }
                 // View
                 $this->template->content = new View('cart_checkout');
                 $this->template->content->cart = $cart;
                 $this->template->content->total = $total;
                 $this->template->content->profile = $profile;
                 $this->template->content->shipping_methods = $shipping_methods;
                 $this->template->content->payment_methods = $payment_methods;
                 $this->template->content->form = $form;
                 $this->template->content->errors = $errors;
             } else {
                 url::redirect('/customer/profile/needed');
             }
         } else {
             url::redirect('/cart/show');
         }
     } else {
         url::redirect('/user/login/login');
     }
 }
Ejemplo n.º 3
0
<?php

include '../config/config.php';
include MODEL_PATH . 'customer.php';
$model = new Customer_Model();
if (isset($_POST['customer_submit']) && $_POST['customer_password'] == $_POST['customer_password_confirmation']) {
    $args = array('customer_name' => FILTER_SANITIZE_SPECIAL_CHARS, 'customer_username' => FILTER_SANITIZE_SPECIAL_CHARS, 'customer_password' => FILTER_SANITIZE_SPECIAL_CHARS, 'customer_email' => FILTER_VALIDATE_EMAIL);
    $input = filter_input_array(INPUT_POST, $args);
    $model->register_customer($input);
} else {
    ?>

<!DOCTYPE html>
<html>
<head>
	<title>Register</title>
	<link rel="stylesheet" type="text/css" href="/shop/src/stylesheet/customer.css">
</head>
<body>
	<div class="register_form_wrapper">
	<div class="form_ribbon">CUSTOMER REGISTRATION</div>
		<form method="POST" action="">
			<label for="customer_name">Full Name</label>
			<input type="text" name="customer_name" placeholder="John Doe" required="required">
			<br>
			<label for="customer_username">Username</label>
			<input type="text" name="customer_username" required="required">
			<br>
			<label for="customer_email">E-mail</label>
			<input type="email" name="customer_email" required="required">
			<br>