0

My program in codeigniter4 does a db updation which after running successully I put a return redirect()->(projectdetail) , but the program shows only a blank page.No redirection happens . My Code:

if($update){
            echo "updating...";

            $projectstatusdetail=$db->table('tbl_projectstatusdetails')
                        ->where('int_projectID',$int_projectID)
                        ->where('int_statusID',$status)
                        ->get()->getRowArray();
            $id=$projectstatusdetail['id'];

            $db->table('tbl_projectstatusdetails')
                 ->where('id',$id)                 
                 ->update($data);

            echo "update completed";//exit;     

            return redirect()->to('projectdetail');



        }

The code prints updating and update completed. But the redirection is not working. How to fix this? .When I did the same in another place where db insertion happens the redirect works.

tanzeem
  • 161
  • 1
  • 3
  • 8
  • "*the program shows only a blank page*", but also "*The code prints updating and update completed*" ...? Those contradict each other, which of these is true? Do you mean the code **should** print that text, but it doesn't? – Don't Panic Mar 21 '23 at 07:10
  • A blank screen could mean there is a PHP error. You need to display or find the error in the logs to understand what the problem is. See https://stackoverflow.com/questions/22911552/php-blank-white-page-no-errors, https://stackoverflow.com/questions/845021/how-can-i-get-useful-error-messages-in-php. – Don't Panic Mar 21 '23 at 07:11
  • What context is this code running in? Is it a method in a controller? https://codeigniter4.github.io/userguide/incoming/controllers.html If the page is truly blank, and does not show at least "updating", then the problem is obvious - your first test `if($update){` evaluates as false. – Don't Panic Mar 21 '23 at 07:15

1 Answers1

0

use

return redirect()->to('url'); 

if you are using route then use

return redirect()->route('named_route');

or

return redirect()->to(site_url());

Please try go to your app->Config->App.php file and then change the $baseURL to your running port like

public string $baseURL = 'http://localhost:8080';

and then try the above code hopefully this will work.

enter image description here

enter image description here