Reputation: 1804
I'm trying to make alert with cross sign. Unfortunately cross sign not working. I have included jquery before bootstrap.js. Here is my model. Thanks in Advance
public function create(){
$data = array('name'=> $this->input->post('name'));
$this->db->insert('dbname', $data);
echo'
<div class="alert alert-success">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>You have successfully posted
</div>
';
exit;
}
Upvotes: 1
Views: 1745
Reputation: 38642
Change this to
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>You have successfully posted
this
<a href="#" class="close" data-dismiss="alert" aria-label="close">×You have successfully posted</a>
And as well as use Model to write data into database. Use follows
In controller
public function create(){
$this->load->model('Model_name');
$result = $this->Model_name->insert_data();
if($result == 1)
{
?>
<div class="alert alert-success">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×You have successfully posted</a>
</div>
<?php
}
else
{
?>
<div class="alert alert-error">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×Failed to poste</a>
</div>
<?php
}
}
In Model
public function insert_data()
{
$data = array(
'name'=> $this->input->post('name')
);
if(!$this->db->insert('dbname', $data))
{
return $log = 0;
}
else
{
return $log = 1;
}
}
Upvotes: 1