在PHP如何使用两个headers位置

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");
?>

我想通过 php 代码发送短信。它工作正常,但问题是我必须使用两个 headers 一个用于短信,另一个用于将我的页面重定向到我想要的位置。但只有第二个在工作。我还想在选项卡中 url 时隐藏我的短信代码的详细信息。并希望同时使用短信和重定向。请帮助?????

如果您只是想发送一些东西,您可以这样做:

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

不漂亮,但在紧要关头可以。

然而,绝对应该使用 curl() 来做到这一点。

header("Location: ..."); 用于将用户重定向到另一个页面。逻辑思考如何同时在 2 个页面上重定向用户。

据我所知,您想给 perfectbulksms.in 打电话 API 发送短信 我强烈建议使用 CURL 来执行此操作,然后使用 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");

这是一个基本示例,阅读有关 CURL 的更多信息http://php.net/manual/en/book.curl.php

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

非常感谢我使用的是 space 而不是 %20 这就是为什么它不起作用感谢 @arun @chris @dass 告诉 curl 选项