Click here to Skip to main content
15,885,890 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
i have problem with redirect after deleted,i want redirect default page but actually after click delete redirect other page
so default page:
PHP
<a href="http://localhost/weekly_report/activity/edit_activity/172"></a>


so here my controller:
PHP
public function delete_activity_edit()
	{
		
		$id=$this->uri->segment(3);
		$this->activity->remove($id);
		redirect('activity/edit_activity/');//i hope i can get data 172
	}


What I have tried:

after i click button delete,successfull but redirect the other page not default page,what add code/variabel in my controller
Posted
Updated 2-Nov-16 1:00am
Comments
asplover1 2-Nov-16 6:55am    
why you use . Does record deleted successfully ???

1 solution

Pass your function name at anchor tag, your function name is " delete_activity_edit " and you call " edit_activity ".
HTML
<a href="http://localhost/weekly_report/activity/delete_activity_edit/172"></a>


then check if it will enters in delete_activity_edit function using echo. Like this;

public function delete_activity_edit()
	{
		
		$id=$this->uri->segment(3);

                echo $id; exit;

		$this->activity->remove($id);
		redirect('activity/edit_activity/');//i hope i can get data 172
	}


then check if it enters into function, it will the 3rd segment value i.e. 172. After that remove 'echo' and 'exit ' and check if record deleted successfully.

Using redirect('activity/edit_activity/'); you will redirect to edit_activity function of activity controller.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900