gpt4 book ai didi

php - 如何在php中将数据发送到另一个文件

转载 作者:行者123 更新时间:2023-11-30 01:34:33 25 4
gpt4 key购买 nike

需要这方面的帮助1. 我需要设计一个用户输入表单,其中包含三个文本字段,即 T1、T2、T3。2. 现在这三个的输入应该打包到encode_json中3.我有一个多行表,自动递增id为1,2,3,4等。现在,相同的编码 json 消息应与 id 和编码 json 消息一起传递到文件 send_message.php 中。这是send_message.php

<?php
if (isset($_GET["regId"]) && isset($_GET["message"])) {
$regId = $_GET["regId"];
$message = $_GET["message"];

include_once './GCM.php';

$gcm = new GCM();

$registatoin_ids = array($regId);
$message = array("price" => $message);

$result = $gcm->send_notification($registatoin_ids, $message);

echo $result;
}
?>

对于与表相关的循环和行数,您可以使用以下内容

if ($no_of_users > 0) {
?>
<?php
while ($row = mysql_fetch_array($users)) {

最佳答案

也许cURL就是您正在寻找的东西。对于每一行,您都可以打开到 send_message.php 的连接并传递您想要的数据。

否则您可以只包含send_message.php,但我不会推荐这样做。

编辑根据您的要求,这是一个非常基本示例:

<?php
$curlPostfields = array(
'field1'=>$value1,
'field2'=>$value2,
);

$curlHandler = curl_init();
curl_setopt($curlHandler, CURLOPT_URL, 'send_message.php');
curl_setopt($curlHandler, CURLOPT_HEADER, false);
curl_setopt($curlHandler, CURLOPT_POST, true);
curl_setopt($curlHandler, CURLOPT_POSTFIELDS, $curlPostfields);
curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curlHandler);

您可以将其打包到一个自己的函数中,然后为表的每一行调用该函数。

关于php - 如何在php中将数据发送到另一个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17080719/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com