Professional CodeIgniter, Thomas Myer
Chapter 5: Building a Shopping Cart
112
}else{
redirect(`welcome/index','refresh');
}
}
}
The next thing you have to do is adjust your product view to read in the flash data saved in your
CodeIgniter session:
<
div id='pleft'
>
<
?php
if ($this-
>
session-
>
flashdata(`conf_msg')){
echo "
<
div class='message'
>
";
echo $this-
>
session-
>
flashdata(`conf_msg');
echo "
<
/div
>
";
}
?
>
<
?php
echo "
<
img src='".$product[`image']."' border='0' align='left'/
>
\n";
echo "
<
h2
>
".$product[`name']."
<
/h2
>
\n";
echo "
<
p
>
".$product[`longdesc'] . "
<
br/
>
\n";
echo "Colors:
<
br/
>
\n";
echo "Sizes:
<
br/
>
\n";
echo anchor(`welcome/cart/'.$product[`id'],'add to cart') . "
<
/p
>
\n";
?
>
<
/div
>
<
div id='pright'
>
<
?php
foreach ($grouplist as $key =
>
$list){
echo "
<
img src='".$list[`thumbnail']."' border='0' align='left'/
>
\n";
echo "
<
h4
>
".$list[`name']."
<
/h4
>
\n";
echo "
<
p
>
";
echo anchor(`welcome/product/'.$list[`id'],'see details') . "
<
br/
>
\n";
echo anchor(`welcome/cart/'.$list[`id'],'add to cart') . "
<
/p
>
\n";
}
?
>
<
/div
>
Finally, add a message class to the CSS file to handle the new message you ' re creating. In the example
below, you ' re creating a message class with red text inside a red - bordered box:
.message{
border:1px solid red;
background-color:#ccc;
color:red;
padding:5px;
width:250px;
font-size:12px;
margin:5px;
}
c05.indd 112
c05.indd 112
6/10/08 5:35:16 PM
6/10/08 5:35:16 PM