Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In PHP how to use two headers Location

<?php 
header("Location:http://www.perfectbulksms.in/Sendsmsapi.aspx
USERID=namePASSWORD=pass&SENDERID=id&TO=$phn&MESSAGE=$sms");
header("Location:password.php?msg=new");
?>

I want to send sms through php code. it is working fine but the problem is i have to use two headers one for the sms and another for to redirect my page on the location i want. but only the second one is working. and i also want to hide the detail of my sms code when it url in the tab. and want to use both sms and redirect. please help?????

like image 543
Yogesh Arya Avatar asked Jun 01 '26 08:06

Yogesh Arya


1 Answers

header("Location: ..."); is use to redirect user to another page. Think logically how can you redirect user on 2 pages at the same time.

As I can see you want to make an API Call to perfectbulksms.in to Send SMS I would highly suggest to use CURL to do so and then use header

    $ch = curl_init("http://www.perfectbulksms.in/Sendsmsapi.aspxUSERID=namePASSWORD=pass&SENDERID=id&TO=$phn&MESSAGE=$sms");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_AUTOREFERER, true);
    $result = curl_exec($ch);
    curl_close($ch);
header("Location:password.php?msg=new");

this is a basic example, Read more about CURL http://php.net/manual/en/book.curl.php

like image 59
Arun Karnawat Avatar answered Jun 02 '26 23:06

Arun Karnawat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!