Is there any way to redirect to external url with parameters from a controller? I'm using joomla 2.5.9 and I have a controller that sends emails to the administrator. After an email is sent successfully, I need to send some details to another site for further proceedings. Can I use cURL like core php ? Here is my controller code :

$mailer = JFactory::getMailer();
            $config = JFactory::getConfig();
            $sender = array($config->getValue( 'config.mailfrom' ),$config->getValue( 'config.fromname' ));
            $admin = JFactory::getUser(42);
            $admin_email = ($admin->email)? $admin->email: $config->getValue( 'config.mailfrom' );
            $mailer->setSubject('New Reservation ('.ucfirst($data['package_hotel']).')');
            $body   = 'Dear Manager,<br><br>'
                    .'<div>You have received a new reservation request ('.$data['package_hotel'].') from '
                    .$data['name'].'. '
                    .'"'.$package_hotel_name.'" '.$data['package_hotel'].' dated '.$data['date_from'].'.</div><br>'
                    .'<div>Name: '.$data['name'].'</div>'
                    .'<div>Address: '.$data['address'].'</div>'
                    .'<div>Email: '.$data['email'].'</div>'
                    .'<div>Mobile Number: '.$data['mobile'].'</div>'
                    .'<div>Phone Number: '.$data['phone'].'</div>'
                    .'<div>Arrival Date: '.$data['date_from'].'</div>'
                    .'<div>Departure Date: '.$data['date_to'].'</div>'
                    .'<div>'.ucfirst($data['package_hotel']).': '.$package_hotel_name.'</div>'
                    .'<div>No of Adults: '.$data['adults'].'</div>'
                    .'<div>No of Children: '.$data['children'].'</div>'
                    .'<div>Comments: '.$data['message'].'</div>'
                    .'<div>Godwin Holidays</div>';
            $mailer->Encoding = 'base64';
            $send = $mailer->Send();

If email sent successfully, then I want to send the above details to some other site say example.com. I'm new to Joomla, so please help me

1 Answer 1


Firstly 2.5.9 is 4 and a half years old and has a number of known security holes.

Secondly, it sounds like you want to make a curl post request and not any kind of redirect.

If the email is sent then the $send variable will be truthy so you would write something like the following straight after your code above.

   // set your destination
   $url = 'https://example.com/have_some_data';

   // build up array of all the data you wish to send
   $fields = array(
       'name' => $data['name'],
       'address' => $data['address']

   // prep data to work with default content type (will probably work)
   $fields_string = http_build_query($fields);

   // send the data
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL,$url);
   curl_setopt($ch, CURLOPT_POST,1);
   curl_setopt($ch, CURLOPT_POSTFIELDS,$fields_string);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   $response = curl_exec($ch);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.