[eluser]Michael Nielsen[/eluser]
Working with the controller below + a form. I just added come css to the form and now when I submit the form I get the follow error:
"Disallowed Key Characters."
I've played around with it but I can't figure it out!
Controller:
Code:
<?php
class Product extends Controller
{
function Product()
{
parent::Controller();
}
function index()
{
echo anchor('store/product/create', 'Add Product');
}
function create()
{
$data['productID'] = random_string('alnum', 15);
$data['manufacture'] = $this->db->get('manufacture');
$data['category'] = $this->db->get('category');
$this->form_validation->set_rules('title', 'Title', 'required');
$this->form_validation->set_rules('price', 'Price', 'required');
$this->form_validation->set_rules('description', 'Description', 'required');
if($this->form_validation->run() == FALSE)
{
$this->load->view('product/create', $data);
}
else
{
if($_POST['category'] == 'Notebook')
{
$product['product_id'] = $_POST['product_id'];
$product['title'] = $_POST['title'];
$product['price'] = $_POST['price'];
$product['manufacture'] = $_POST['manufacture'];
$product['category'] = $_POST['category'];
$notebook['product_id'] = $product['product_id'];
$notebook['description'] = $_POST['description'];
$this->db->insert('product', $product);
$this->db->insert('notebook_detail', $notebook);
redirect('store/product');
}
}
}
}
?>
View:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Store / Add New Product</title>
<link href="../../../../../style/store.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<?=validation_errors();?>
<?=form_open('store/product/create')?>
<table cellspacing="2">
<tr>
<td colspan="2">Product Information</td>
</tr>
<tr>
<td>Title</td>
<td><div align="left">
<input type="text" name="title" value="" size="" />
</div></td>
</tr>
<tr>
<td>Price</td>
<td><div align="left">
<input type="text" name="price" value="" size="" />
</div></td>
</tr>
<tr>
<td>Description</td>
<td><div align="left">
<input type="text" name="description>" />
</div></td>
</tr>
<tr>
<td>Manufacture</td>
<td>
<div align="left">
<select name="manufacture">
<?
foreach($manufacture->result() as $row):
echo '<option value="'.$row->manufacture.'">'.$row->manufacture.'</option>';
endforeach;
?>
</select>
</div></td>
</tr>
<tr>
<td>Category</td>
<td>
<div align="left">
<select name="category">
<?
foreach($category->result() as $row):
echo '<option value="'.$row->category.'">'.$row->category.'</option>';
endforeach;
?>
</select>
</div></td>
</tr>
<tr>
<td colspan="2"><div align="right"><input type="hidden" name="product_id" value="<?=$productID?>"/><input type="submit" value="Submit" /></div></td>
</tr>
</table>
</form>
</body>
</html>