標題: 點可以一張form同時submit去2個不同php?
 pat
 0020100
Rank: 6Rank: 6Rank: 6Rank: 6Rank: 6Rank: 6

頭銜: Forum Legend

帖子: 1607

精華: 0

積分: 3500 點

現金: 271 元

存款: 24500 元

閱讀權限: 70

註冊: 2005-4-30

來自: HK

狀態: 離線
 
發表於 2008-7-23 01:33  資料  個人空間  主頁 短消息  加為好友  添加 pat 為MSN好友 通過MSN和 pat 交談 ICQ 狀態 Yahoo!
點可以一張form同時submit去2個不同php?

<form id = "1" name="oop" method = "post" action = "welcome.php">
<input type="text" name = "hi" />
</form>
有2個php, 都係post method, 一個叫welcome.php, 一個叫index.php
我有諗過彈另一個page出黎, 但係又唔知點pass d parameter..




正在建立1隻php game, 所以關於php問題會比較多~
歡迎大家給予圖片製作資訊
 AL8 Forum © All rights reserved.
頂部
 bananasims
 0025881
Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8
點擊查看 bananasims 的詳細資料

頭銜: Super Moderator

帖子: 12124

精華: 0

積分: 27215 點

現金: 345 元

存款: 84490 元

閱讀權限: 110

註冊: 2005-7-10

狀態: 離線
 
發表於 2008-7-23 09:58  資料  個人空間  主頁 短消息  加為好友 
http://bbs.i-circle.net/viewtopic.php?f=100&t=6022
    <?php
    // Generate the request header
    $ReqHeader =
    "POST $URI HTTP/1.1\n".
    "Host: $Host\n".
    "Content-Type: application/x-www-form-urlencoded\n".
    "Content-Length: $ContentLengthn\n".
    "$ReqBody\n";
    // Open the connection to the host
    $socket = fsockopen($Host, 80, &$errno, &$errstr);
    if (!$socket){
       $Result["errno"] = $errno;
       $Result["errstr"] = $errstr;
       return $Result;
    }
    $idx = 0;
    fputs($socket, $ReqHeader);
    while (!feof($socket)){
       $Result[$idx++] = fgets($socket, 128);
    }
    //-------------------------------------------
    ?>


[ 本帖最後由 bananasims 於 2008-7-23 13:14 編輯 ]




 AL8 Forum © All rights reserved.
頂部
 ntf
 0043014
Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7

頭銜: Moderator

自述: ntf

帖子: 3713

精華: 0

積分: 6403 點

現金: 0 元

存款: 38423 元

閱讀權限: 100

註冊: 2006-4-7

狀態: 離線
 
發表於 2008-7-23 11:48  資料  個人空間  短消息  加為好友 
回覆 #2 bananasims 的帖子

唔係俾個唔得既人啦= =

全部都要
"POST $URI HTTP/1.1 \n".




 AL8 Forum © All rights reserved.
頂部
 bananasims
 0025881
Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8
點擊查看 bananasims 的詳細資料

頭銜: Super Moderator

帖子: 12124

精華: 0

積分: 27215 點

現金: 345 元

存款: 84490 元

閱讀權限: 110

註冊: 2005-7-10

狀態: 離線
 
發表於 2008-7-23 13:14  資料  個人空間  主頁 短消息  加為好友 
回覆 #3 ntf 的帖子

我未試過   不過陣係見過呢樣
我 search 都 search 唔到,成日見到咩 header location




 AL8 Forum © All rights reserved.
頂部
 waterhk
 0017105
Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7

頭銜: Moderator

帖子: 238

精華: 0

積分: 2335 點

現金: 54 元

存款: 0 元

閱讀權限: 100

註冊: 2005-2-25

狀態: 離線
 
發表於 2008-7-23 14:09  資料  個人空間  短消息  加為好友 
以目前黎講可以通過 AJAX.
以以前黎講可以通過 Frame 既方式
其實好多方法都得..




與其給你魚吃,不如教你釣魚的方法
 AL8 Forum © All rights reserved.
頂部
 ntf
 0043014
Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7

頭銜: Moderator

自述: ntf

帖子: 3713

精華: 0

積分: 6403 點

現金: 0 元

存款: 38423 元

閱讀權限: 100

註冊: 2006-4-7

狀態: 離線
 
發表於 2008-7-23 16:20  資料  個人空間  短消息  加為好友 
回覆 #4 bananasims 的帖子

search http socket post

我改左個

冇時間整靚d
<?php
/*
* Light Environment Framework  (c) NTF
* Author: ntf
* Version: Pre-Alpha 1.0
* Last modified: 23/7/2008 17:51
*  Http socket Tool
*
*/
class HTTPSocket {
private $resource;
private $headers;
private $content;
function HTTPSocket($Socketdata=array()){
$this->resource['url']=$Socketdata['url'];
$this->resource['timeout']=isset($Socketdata['timeout'])?$Socketdata['timeout']:60;
$this->resource['get']=array();
$this->resource['cookie']=array();
$this->resource['post']=array();
}
function url($url){
$this->resource['url']=$url;
}

function timeout($timeout){
$this->resource['timeout']=($timeout>5)?$timeout:60;
}

function add_header($add_header_str) {
        $this->headers[]= $add_header_str;;
    }
   
function set_header($set_header_str) {
        $this->headers=array($set_header_str);
}
   
   function add_get($arrParam) {
               $this->resource['get'][]=http_build_query($arrParam); //       $this->url .= (strpos($this->url,'?') === false?'?':'&').
    }
   function add_post($arrParam) {
                $this->resource['post'][]= http_build_query($arrParam);
    }

  function set_useragent($Useragent){
                  $this->headers['useragent']="User-Agent:{$Useragent}";
  }
  function set_referer($Referer){
                  $this->headers['referer']="Referer:{$Referer}";
  }
  function set_cookie($set_cookiename,$set_cookievalue){
          $this->resource['cookie'][$set_cookiename]=$set_cookievalue;
  }
  function del_cookie($set_cookiename){
          unset($this->resource['cookie'][$set_cookiename]);
  }
  function connect(){
  $errno=$errstr='';
  $limit=0;
          $matches = parse_url($this->resource['url'].(strpos($this->resource['url'],'?') === false?'?':'&').implode('&',$this->resource['get']));
        $host = $matches['host'];
        $path = $matches['path'] ? $matches['path'].'?'.$matches['query'].'#'.$matches['fragment'] : '/';
        $port = !empty($matches['port']) ? $matches['port'] : 80;
        $this->headers['useragent']=(!empty($this->headers['useragent']))?$this->headers['useragent']: "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
          $fp = fsockopen($host,$port, $errno, $errstr,$this->resource['timeout']);
        if(!$fp) {
                return $errstr.'|'.$errno;
  }else{
         
          if(empty($this->resource['post'])){
                          $out = "GET $path HTTP/1.0\r\n";
          }else{
                    $out = "POST $path HTTP/1.0\r\n";
          }
                $out .= "Accept: */*\r\n";
                $out .= "Accept-Language: zh-hk\r\n";
                $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
               
                $out .= "Host: $host\r\n";
                if(!empty($this->resource['post'])){
                        $out .= 'Content-Length: '.strlen(implode('',$this->resource['post']))."\r\n";
                }
                $out.=implode("\r\n",$this->headers);
                $out .= "Connection: Close\r\n";
                $out .= "Cache-Control: no-cache\r\n";
               
                        $outcookie=array();
                        if(is_array($this->resource['cookie'])){
                                foreach($this->resource['cookie'] as $key => $value){
                                        $outcookie[]="{$key}={$value}";
                                }
                        }
                       
                $out .= "Cookie: ".implode('&',$outcookie)."\r\n\r\n";
                $out .= is_array($this->resource['post'])?implode("&",$this->resource['post']):'';
                stream_set_blocking($fp,true);
                stream_set_timeout($fp, $this->extra['timeout']);
                @fwrite($fp, $out);
                $status = stream_get_meta_data($fp);
                if(!$status['timed_out']) {
                        while (!feof($fp)) {
                                if(($header = @fgets($fp)) && ($header == "\r\n" ||  $header == "\n")) {
                                        break;
                                }
                        }

                        $stop = false;
                        while(!feof($fp) && !$stop) {
                                $data = fread($fp, ($limit == 0 || $limit > 8192 ? 8192 : $limit));
                                $return .= $data;
                                if($limit) {
                                        $limit -= strlen($data);
                                        $stop = $limit <= 0;
                                }
                        }
                }
                @fclose($fp);
                $this->content=$return;
                return$this->content;
         }
  }
  
  function insert($inserttype){
          switch($inserttype){
                  case'baseurl':
                  $matches = parse_url($this->resource['url']);
            $matches['port'] = !empty($matches['port']) ? $matches['port'] : 80;
                  $insert_find='/<head>(.*)<\/head>/s';
                  $insert_replace='<head>\1<base href="http://'.$matches['host'].':'.$matches['port']. $matches['path'].'"/></head>';
                  break;
          }
         
          $this->content=preg_replace($insert_find,$insert_replace,$this->content);
          return $this->content;
  }
  
  function content(){
          return $this->content;
  }
  
  function reset(){
          $this->HTTPSocket();
          $this->content='';
  }
}

?>




 AL8 Forum © All rights reserved.
頂部
 bananasims
 0025881
Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8
點擊查看 bananasims 的詳細資料

頭銜: Super Moderator

帖子: 12124

精華: 0

積分: 27215 點

現金: 345 元

存款: 84490 元

閱讀權限: 110

註冊: 2005-7-10

狀態: 離線
 
發表於 2008-7-23 17:38  資料  個人空間  主頁 短消息  加為好友 
我想知你有冇 coding standard =.= 好難睇
成堆野痴埋一舊




 AL8 Forum © All rights reserved.
頂部
 ntf
 0043014
Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7

頭銜: Moderator

自述: ntf

帖子: 3713

精華: 0

積分: 6403 點

現金: 0 元

存款: 38423 元

閱讀權限: 100

註冊: 2006-4-7

狀態: 離線
 
發表於 2008-7-23 18:31  資料  個人空間  短消息  加為好友 
回覆 #7 bananasims 的帖子

coding standard - -

都話 呢個冇時間整靚d = =

如果要用既話

               
                $Connect=new HTTPSocket();
                $Connect->url('http://www.alan888.com/Discuz/');
                $Connect->add_post(array('test'=>'value')); // 使用 $_POST 都得
                $Connect->connect();


[ 本帖最後由 ntf 於 2008-7-23 18:34 編輯 ]




 AL8 Forum © All rights reserved.
頂部


網頁空間由 I-SERVICES 提供
當前時區 GMT+8, 現在時間是 2008-12-5 08:47