[eluser]bluepicaso[/eluser]
hello people..a problem im facing is related to the refreshing of the page.i haven't worked on CI before this is my first ever project most of which has to be completed by tomorrow to show to client..
The view submits the value to the controller, the controller passes it to the model.
The model saves it into the database....
the controller then redirects to the same view from which it all started...
But on refreshing the page the value still gets into the database...i dont want this.. is there a way to clear these post values....
below is the code....
View named admin_insert
Code:
<?php echo $sub;?>
<?php echo form_open("insert/main_cat")?>
<table>
<tr>
<td>
Main Category
</td>
<td>
<input type="text" name="cat">
</td>
</tr>
<tr>
<td>
<input type="submit" value="Save">
</td>
</tr>
</table>
<?php form_close();?>
controller named insert
Code:
<?php
class Insert extends Controller
{
function Insert()
{
parent::Controller();
}
function main_cat()
{
$cat = $this->input->post('cat');
$this->load->model('insertmodel');
$data['sub'] = $this->insertmodel->setCat($cat);
if($data['sub'] == 1)
{
unset($_POST);
$this->load->view('admin_insert', $data);
}
else
{
//--------data not inserted------------
echo "Oops data is not inserted<br> Please go back and resubmit <br> OR <br> Try refreshing the page";
}
}
}
?>
Model named insertmodel
Code:
<?php
class insertModel extends Model
{
function insertModel()
{
parent::Model();
}
function setCat($a)
{
//$b = md5($b);
$x = $this->db->query("insert into main (name) values ('$a')");
return $x;
}
}
?>