2017-08-07 73 views
0
echo ' 
<body onload="document.subfrm.submit()"> 
     <form method=post action="index.php?" name="subfrm"> 
<input type=hidden name="mnux" value="master.dosen"> 
<input type=hidden name="gos" value="DsnEdt"> 
<input type=hidden name="md" value="0"> 
<input type=hidden name="dsnid" value="'.$dsncr.'"> 

</form> 
    </body> 
    <noscript><meta http-equiv="refresh" content="0; url=JavascriptHarusDinyalakan.html" /></noscript> 
    <noscript><p>Please enable JavaScript in your browser for better use of the website.</p></noscript> 
'; 

的我這裏http://form.guide/php-form/php-form-submit.html 都嘗試的方法,但他們沒有重定向到新的頁面PHP相當於這個網站的onload

+0

IM相信的時候,你需要使用document.getElementByName( 'subfrm')[0]在身體onload –

回答

0
<?php 
    if(isset($_POST['submit'])) 
    { 
     function do_post_request($url, $data, $optional_headers = null) 
     { 
      $params = array('http' => array(
          'method' => 'POST', 
          'content' => $data 
         )); 
      if($optional_headers != null) 
      { 
       $params['http']['header'] = $optional_headers; 
      } 
      $ctx = stream_context_create($params); 
      $fp = @fopen($url, 'rb', false, $ctx); 
      if (!$fp) 
      { 
       throw new Exception("Problem with $url, $php_errormsg"); 
      } 
      $response=''; 
      while (!feof($fp)) 
      { 
       $response = $response.fgets($fp); 
      } 
      if ($response === false) 
      { 
       throw new Exception("Problem reading data from $url, $php_errormsg"); 
      } 

      fclose($fp); 
      return $response; 
     } 
     $host = 'http://mydomain.in'; 
     $url = 'http://mydomain.in/formHandler.php'; 
     $username = 'admin'; 
     $password = '123456'; 
     $data = array ('action' => 'login','lgname' => $username, 'lgpassword' => $password, 'format' => 'txt'); 
     $data = http_build_query($data); 
     $reply = do_post_request($url, $data); 
     echo "**********Response*********<pre>"; 
     echo var_dump($reply); 
     #header('location:'.$host); 
     #exit; 

     } 
else { 
    echo '<form method="post" enctype="multipart/form-data" action="'.$_SERVER['PHP_SELF'].'"><input type="text" name="uname" /><br><input type="password" name="password" /><input type="submit" name="submit"></form>'; 

     } 

    ?> 
+0

是這種形式的數據不可見通過查看源等瀏覽器? –

+0

是的,如果你sumbit數據表單變得不可見 –

+0

仍然沒有重定向 –