A very simple question, however, I do not know or remember. How can I send data from one php file to another, tb in php? This is not the case for form.
File php 1:
header('Content-Type: text/html; charset=utf-8');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type,X-Prototype-Version,X Requested-With');
include_once("conPDO.php");
$pdo = conectar();
$msg = utf8_decode($_GET['mensagem']);
$idUsuario = $_GET['idUsuario'];
$idCep = $_GET['idCep'];
$nomeRemetente = $_GET['nome'];
$usuarioRemetente = $_GET['usuario'];
$uf = $_GET['uf'];
$cidade = $_GET['cidade'];
$bairro = $_GET['bairro'];
$logradouro = $_GET['logradouro'];
$dia = $_GET['dia'];
$hora = $_GET['hora'];
$foto = '';
$cidade = utf8_decode($cidade);
$bairro = utf8_decode($bairro);
$logradouro = utf8_decode($logradouro);
header('Location: websocket/src/MyApp/Chat.php?msg='.$msg);
I want to pass these variables, above, to the following php below
Php 2 file:
<?php
$msg = $_GET['msg'];
echo $msg;
namespace MyApp;
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;
class Chat implements MessageComponentInterface {
protected $clients;
public function __construct() {
$this->clients = new \SplObjectStorage;
}
public function onOpen(ConnectionInterface $conn) {
// Store the new connection to send messages to later
$this->clients->attach($conn);
echo "New connection! ({$conn->resourceId})\n";
}
public function onMessage(ConnectionInterface $from, $msg) {
$numRecv = count($this->clients) - 1;
echo sprintf('Connection %d sending message "%s" to %d other connection%s' . "\n"
, $from->resourceId, $msg, $numRecv, $numRecv == 1 ? '' : 's');
$dados = json_decode($msg, true);
$dados['id'] = $from->resourceId;
foreach ($this->clients as $client) {
// The sender is not the receiver, send to each client connected
$client->send(json_encode($dados));
}
}