• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cannot modify header

Hello i don t understand, i want create an alert just before redirect my page so i try this :

function desinscrire($event_id){
        $user_login_id = $this->session->userdata('id');

but i have this error :

A PHP Error was encountered
Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/lovemeet/www/siteweb/application/controllers/evenements.php:746)

Filename: helpers/url_helper.php

Line Number: 565

ligne 746 is : echo"[removed]alert('ok')[removed]";

Why don t work ?

[removed] = < script > without space
Thank you

redirect() function uses php's header() function for redirect.
in order for header() to work properly, nothing needs to be echo before it is called, else, you will get an error, like you did .

Read more about header() and you will get the point .

ok thanks i understand, so how can i do for create an alert JS before redirect my page ? thank you

If i were you, i would use session->set_flashdata(); and add a variable there right before redirect, then after the redirect is done and the new page is loaded, do a check for the flashdata variable and if it is present, do the alert then .

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.