Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ethar's avatar
Level 5

redirect not working after execute curl

curl code executed successfully, but redirect not working, plz how redirect after execute

 $ch = curl_init ();
        curl_setopt ( $ch, CURLOPT_URL, $url );
        curl_setopt ( $ch, CURLOPT_POST, true );
        curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
        curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
        curl_setopt ( $ch, CURLOPT_POSTFIELDS, $fields );
        $exec = curl_exec($ch);
        $result = json_decode($exec);
        if($result->success == 1){
            $status='success';
            $msg='notifi sent';
        }else{
            $status = 'error';
            $msg = $status;
        }
        curl_close($ch);
        return redirect('/admin/notification')->with($status, $msg);
0 likes
2 replies
s4muel's avatar
s4muel
Best Answer
Level 50

is that in your contoller (or routes file callback) or somewhere else? what does it return then?

1 like
ethar's avatar
Level 5

@s4muel thanks for you, its trait, so now i know where is my wrong

1 like

Please or to participate in this conversation.