probleme de redirection - PHP - Programmation
Marsh Posté le 21-01-2010 à 16:27:09
Code :
  | 
  
 
On n'écrit rien avant la redirection. Donc soit tu fait un vil pop-up js qui, à la fermeture, lance la redirection, soit tu écris ton message de confirmation sur la page cible de la redirection.
Marsh Posté le 21-01-2010 à 16:29:54
Et pour faire une redirection avec header, il faut mettre "location: http://xxxxx".
Marsh Posté le 21-01-2010 à 18:14:17
| kao98 a écrit : Et pour faire une redirection avec header, il faut mettre "location: http://xxxxx".  | 
 
 
 
comme ceci 
 
  $message = "bonjour campus-descartes.net vous souhaite une bonne annee 2010 et bientot sur notre site "; 
$image =  "http://localhost:8888/MMS/image1.jpg"; 
if(send_sms($cible,$message,$image))  {echo("sms ok au : $cible" 
   header('location: http://localhost:8888/MMS/p3.php');   
    }  else echo("Impossible de trouver le token ou message trop long. Message non transmis. Mauvais logins ?" ); 
 
 
Marsh Posté le 21-01-2010 à 18:40:29
en faite voila je voudrais faire une boucle du programme complait tant que la valeur $cible < $ciblefin   
et add 1 dans $cible  
retour au programme   
le programme marche tres bien mais ???  
la 1er page  demande:  
$cible  
$ciblefin  
 et je récupère an post  
je pense a un solution   
page 1  donnée  
page  2 traitement   
page 3   
verification   
$cible<$ciblefin   
retour page 2  
  
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />  
<title>Untitled Document</title>  
</head>  
  
<body>  
  
  
  
<?php   
  
$ciblefin = $_POST['$ciblefin'];  
$cible = $_POST['$cible'];  
  
disons ici    
  
Define('AUTHENTIFICATION', 'http://------------------------------------------------/');  
Define('COOKIE_FILE','cookie.txt');        
Define('EMPTY_FILE',"emptyfile.txt" );       
Define('USER_AGENT','Mozilla/5.0');        
Define('LOGIN','---------');         
Define('PASSWORD','-------');  
  
  
  
  
  
  
$message = "Message à envoyer blllllllllllllllllllllllaaaaaaaaaaaaaaaaaa";  
$image =  "image1.jpg";  
if(send_sms($cible,$message,$image)) echo("sms ok au : $cible" );  
else echo("Impossible de trouver le token ou message trop long. Message non transmis. Mauvais logins ?" );  
  
/  
function send_sms($cible,$message,$image)  
{  
 //Encodage d  
 $message = utf8_decode($message);  
   
 $ch = curl_init();  
   
 // set url  
 curl_setopt($ch, CURLOPT_URL, AUTHENTIFICATION);  
 curl_setopt($ch, CURLOPT_COOKIEJAR, realpath(COOKIE_FILE));  
 curl_setopt($ch, CURLOPT_COOKIEFILE, realpath(COOKIE_FILE));  
 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);  
 curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);  
 curl_setopt($ch, CURLOPT_USERAGENT, USER_AGENT);  
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
   
 // $output contains the output string  
 $output = curl_exec($ch);  
   
 curl_close($ch);  
    
 $ch = curl_init();  
 curl_setopt($ch, CURLOPT_URL, "https://www.------------------------------spring_cas_security_check" );  
 curl_setopt($ch, CURLOPT_POST, TRUE);  
 curl_setopt($ch, CURLOPT_POSTFIELDS,"target=&_eventId=¤tPage=&username=".LOGIN."&password=".PASSWORD);  
 curl_setopt($ch, CURLOPT_COOKIEJAR, realpath(COOKIE_FILE));  
 curl_setopt($ch, CURLOPT_COOKIEFILE, realpath(COOKIE_FILE));  
 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);  
 curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);  
 curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);  
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);  
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
   
 $ret = curl_exec($ch);  
   
 curl_setopt($ch, CURLOPT_URL, "----------/index.do" );  
  
   
 $ret = curl_exec($ch);  
   
 if ($ret === FALSE) {  
     die(curl_errno($ch));  
 }  
   
 preg_match("!\"CSRFToken\" value=\"([0-9]*)!",$ret,$out);  
   
 if(!isset($out[1]))  
 {  
  return 0;  
 }  
   
 $token = $out[1];  
   
 $array = Array(  
 "CSRFToken" => $token,  
 "idMessage" => '',  
 "submitMethod" => 'web',  
 "todo" => '',  
 "boxId" => 'sent',  
 'galleryItem' => '-1',  
 'msisdns' => $cible,  
 'emails' => '',  
 'emoticones' => '',  
 'message' => $message,  
 'file' => '@'.realpath(EMPTY_FILE)  
 );  
   
 curl_setopt($ch, CURLOPT_URL, "http://www.-------------------------------------------/submit.do" );  
 curl_setopt($ch, CURLOPT_COOKIEJAR, realpath(COOKIE_FILE));  
 curl_setopt($ch, CURLOPT_COOKIEFILE, realpath(COOKIE_FILE));  
 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);  
 curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);  
 curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);  
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);  
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
 curl_setopt($ch, CURLOPT_POST, TRUE);  
 curl_setopt($ch, CURLOPT_POSTFIELDS,$array);  
 $ret = curl_exec($ch);  
  
 preg_match("!\"CSRFToken\" value=\"([0-9]*)!",$ret,$out);  
 $token = $out[1];  
   
 //Confirmation  
 $array = Array(  
 "CSRFToken" => $token,  
 "idMessage" => '',  
 "submitMethod" => 'web',  
 "todo" => '',  
 "boxId" => 'sent',  
 'emoticones' => '',  
 'mms' => 'false',  
 'message' => $message  
 );  
   
 curl_setopt($ch, CURLOPT_URL, "http://www.-----------------------------------------------------------------" );  
 curl_setopt($ch, CURLOPT_POST, TRUE);  
 curl_setopt($ch, CURLOPT_POSTFIELDS,$array);  
 $ret = curl_exec($ch);  
 curl_close($ch);  
  
 if(strpos($ret,"Le Texto a été expédié avec succès !" ) === false) return 0;  
 else return 1;  
    
 return 1;  
 }   
  
  
  
?>  
  
  
</body>  
</html> 
Marsh Posté le 21-01-2010 à 16:12:46