Welcome Guest, Not a member yet? Register   Sign In
Shopping Cart
#1

http://localhost/ShoppingCart/

Shopping Cart


Fatal error: Call to undefined function form_open() in C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\ShoppingCart\application\views\welcome_message.php on line 70
A PHP Error was encountered
Severity: Error
Message: Call to undefined function form_open()
Filename: views/welcome_message.php
Line Number: 70
Backtrace:


I already input shopping cart codes into the following messages:

views/welcome_message.php

PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Welcome to CodeIgniter</title>

    <style type="text/css">

    ::selection { background-color: #E13300; color: white; }
    ::-moz-selection { background-color: #E13300; color: white; }

    body {
        background-color: #fff;
        margin: 40px;
        font: 13px/20px normal Helvetica, Arial, sans-serif;
        color: #4F5155;
    }

    a {
        color: #003399;
        background-color: transparent;
        font-weight: normal;
    }

    h1 {
        color: #444;
        background-color: transparent;
        border-bottom: 1px solid #D0D0D0;
        font-size: 19px;
        font-weight: normal;
        margin: 0 0 14px 0;
        padding: 14px 15px 10px 15px;
    }

    code {
        font-family: Consolas, Monaco, Courier New, Courier, monospace;
        font-size: 12px;
        background-color: #f9f9f9;
        border: 1px solid #D0D0D0;
        color: #002166;
        display: block;
        margin: 14px 0 14px 0;
        padding: 12px 10px 12px 10px;
    }

    #body {
        margin: 0 15px 0 15px;
    }

    p.footer {
        text-align: right;
        font-size: 11px;
        border-top: 1px solid #D0D0D0;
        line-height: 32px;
        padding: 0 10px 0 10px;
        margin: 20px 0 0 0;
    }

    #container {
        margin: 10px;
        border: 1px solid #D0D0D0;
        box-shadow: 0 0 8px #D0D0D0;
    }
    </style>
</head>
<body>

<?php echo form_open('path/to/controller/update/method'); ?>

<table cellpadding="6" cellspacing="1" style="width:100%" border="0">

<tr>
        <th>QTY</th>
        <th>Item Description</th>
        <th style="text-align:right">Item Price</th>
        <th style="text-align:right">Sub-Total</th>
</tr>

<?php $i 1?>

<?php foreach ($this->cart->contents() as $items): ?>

        <?php echo form_hidden($i.'[rowid]'$items['rowid']); ?>

        <tr>
                <td><?php echo form_input(array('name' => $i.'[qty]''value' => $items['qty'], 'maxlength' => '3''size' => '5')); ?></td>
                <td>
                        <?php echo $items['name']; ?>

                        <?php if ($this->cart->has_options($items['rowid']) == TRUE): ?>

                                <p>
                                        <?php foreach ($this->cart->product_options($items['rowid']) as $option_name => $option_value): ?>

                                                <strong><?php echo $option_name?>:</strong> <?php echo $option_value?><br />

                                        <?php endforeach; ?>
                                </p>

                        <?php endif; ?>

                </td>
                <td style="text-align:right"><?php echo $this->cart->format_number($items['price']); ?></td>
                <td style="text-align:right">$<?php echo $this->cart->format_number($items['subtotal']); ?></td>
        </tr>

<?php $i++; ?>

<?php endforeach; ?>

<tr>
        <td colspan="2"> </td>
        <td class="right"><strong>Total</strong></td>
        <td class="right">$<?php echo $this->cart->format_number($this->cart->total()); ?></td>
</tr>

</table>

<p><?php echo form_submit('''Update your Cart'); ?></p>

</body>
</html> 


controllers/Welcome.php

PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Welcome extends CI_Controller {

    
/**
     * Index Page for this controller.
     *
     * Maps to the following URL
     *         http://example.com/index.php/welcome
     *    - or -
     *         http://example.com/index.php/welcome/index
     *    - or -
     * Since this controller is set as the default controller in
     * config/routes.php, it's displayed at http://example.com/
     *
     * So any other public methods not prefixed with an underscore will
     * map to /index.php/welcome/<method_name>
     * @see https://codeigniter.com/user_guide/general/urls.html
     */
    
public function index()
    {
        
$this->load->view('welcome_message');
        
        
$data = array(
 
       array(
 
               'id'      => 'sku_123ABC',
 
               'qty'     => 1,
 
               'price'   => 39.95,
 
               'name'    => 'T-Shirt',
 
               'options' => array('Size' => 'L''Color' => 'Red')
 
       ),
 
       array(
 
               'id'      => 'sku_567ZYX',
 
               'qty'     => 1,
 
               'price'   => 9.95,
 
               'name'    => 'Coffee Mug'
 
       ),
 
       array(
 
               'id'      => 'sku_965QRS',
 
               'qty'     => 1,
 
               'price'   => 29.95,
 
               'name'    => 'Shot Glass'
 
       )
        );

    
$this->cart->insert($data);
    }



Can anyone help me detect the errors?
" If I looks more intelligence please increase my reputation."
Reply


Messages In This Thread
Shopping Cart - by davy_yg - 05-12-2016, 11:49 AM
RE: Shopping Cart - by albertleao - 05-12-2016, 12:21 PM
RE: Shopping Cart - by albertleao - 05-12-2016, 12:22 PM
RE: Shopping Cart - by cartalot - 05-12-2016, 01:59 PM
RE: Shopping Cart - by davy_yg - 05-12-2016, 05:53 PM
RE: Shopping Cart - by cartalot - 05-13-2016, 11:03 AM
RE: Shopping Cart - by albertleao - 05-13-2016, 12:01 PM
RE: Shopping Cart - by cartalot - 05-13-2016, 12:30 PM



Theme © iAndrew 2016 - Forum software by © MyBB