utilisation de POST
Posté : 03 mai 2012, 15:53
Bonjour à tous,
je tente (désespérément
de transmettre le contenu d'une variable d'un fichier1.php à un fichier2.php : merci de votre aide !
dans mes essais j'ai utilisé curl qui est bien installé sur mon ordi
ce que j'ai tenté : (afin d'informer dans fichier2.php la variable $content
------------------------------------------ci-dessous fichier1.php
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost/smswall/admin/registersmswall.php/");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$data = array(
'text' => 'messagesms',
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$contents = curl_exec($ch);
curl_close($ch);
echo $data[text];
?>
----------------------------------------
------------------------------------------------ et plus bas le fichier qui doit recevoir la variable (fichier2.php)
<?php
include('init_db.php');
$title = "";
$link = "SMS";
$content = strip_tags($_POST['text']); <============== c'est $content que je veux renseigner !!!
echo $content;
$timestamp = time();
$modo_type = $config['modo_type'];
$etat_bulle = $config['bulle'];
//$db->exec('INSERT INTO "items" VALUES(NULL,'.$db->quote($title).','.$db->quote($link).','.$db->quote($content).','.$timestamp.','.$modo_type.');');
$db->exec('INSERT INTO "items" VALUES(NULL,'.$db->quote($title).','.$db->quote($link).','.$db->quote($content).','.$timestamp.','.$modo_type.','.$etat_bulle.',NULL);');
?>
je tente (désespérément
dans mes essais j'ai utilisé curl qui est bien installé sur mon ordi
ce que j'ai tenté : (afin d'informer dans fichier2.php la variable $content
------------------------------------------ci-dessous fichier1.php
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost/smswall/admin/registersmswall.php/");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$data = array(
'text' => 'messagesms',
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$contents = curl_exec($ch);
curl_close($ch);
echo $data[text];
?>
----------------------------------------
------------------------------------------------ et plus bas le fichier qui doit recevoir la variable (fichier2.php)
<?php
include('init_db.php');
$title = "";
$link = "SMS";
$content = strip_tags($_POST['text']); <============== c'est $content que je veux renseigner !!!
echo $content;
$timestamp = time();
$modo_type = $config['modo_type'];
$etat_bulle = $config['bulle'];
//$db->exec('INSERT INTO "items" VALUES(NULL,'.$db->quote($title).','.$db->quote($link).','.$db->quote($content).','.$timestamp.','.$modo_type.');');
$db->exec('INSERT INTO "items" VALUES(NULL,'.$db->quote($title).','.$db->quote($link).','.$db->quote($content).','.$timestamp.','.$modo_type.','.$etat_bulle.',NULL);');
?>