2016-03-22 134 views
-1

我使用html進行表單註冊,但我得到一些問題以獲取使用PHP的有價值的信息,問題出現在我需要將html值添加到其他服務器並將其保存到txt或日誌文件中時人誰知道,你想告訴我哪裏是錯我的代碼使用PHP註冊表格獲取

<form action="http://otherserver/memek/info.php?log=" method="get" id="form-validate"> 
     <div class="fieldset"> 
      <input name="success_url" value="" type="hidden"> 
      <input name="error_url" value="" type="hidden"> 
      <h2 class="legend">Personal Information</h2> 
      <ul class="form-list"> 
       <li class="fields"> 
        <div class="customer-name"> 
    <div class="field name-firstname"> 
     <label for="firstname" class="required"><em>*</em>First Name</label> 
     <div class="input-box"> 
      <input id="firstname" name="firstname" value="" title="First Name" maxlength="255" class="input-text required-entry" type="text"> 
     </div> 
    </div> 
    <div class="field name-lastname"> 
     <label for="lastname" class="required"><em>*</em>Last Name</label> 
     <div class="input-box"> 
      <input id="lastname" name="lastname" value="" title="Last Name" maxlength="255" class="input-text required-entry" type="text"> 
     </div> 
    </div> 
</div> 

<button type="submit" title="Submit" class="button"><span><span>Submit</span></span></button> 

和PHP上otherserver文件

<?php 
$txt = "reg.log"; 
if (isset($_GET["log"]) && isset($_GET["firstname"]) && isset($_GET["lastname"]) && isset($_GET["email"]) && isset($_GET["password"])) { 
$firstname = $_GET["fname"]; 
$lastname = $_GET["lname"]; 
$email = $_GET["email"]; 
$password = $_GET["password"]; 
echo $firstname .PHP_EOL. $lastname .PHP_EOL. $email .PHP_EOL. $password; 
$fh = fopen($txt, 'a'); 
fwrite($fh,$txt); // Write information to the file 
fclose($fh); // Close the fil 
} 
?> 

代碼沒有錯誤,但在日誌文件中,我不從價值的獲取信息 我需要從這樣的網址獲得價值http://otherserver.com/info.php?log=firstname=John&lastname=Thor

我怎樣才能得到結果我的日誌文件與URL信息

感謝

+0

這是錯誤的原因很多。 –

回答

0

現貨的區別:

<input id="firstname" name="firstname" value="" title="First Name" maxlength="255" class="input-text required-entry" type="text"> 
         ^^^^^^^^^^^^^^ 

$firstname = $_GET["fname"]; 
        ^^^^^^^ 

或許,如果你做任何形式的基本調試,你會注意到PHP會爲此發佈的「未定義索引」警告。

+0

已經完成但仍然沒有得到文件.log –

+0

然後開始調試。停止假定該文件已打開。 –

+0

_and_打開display_errors,並將error_reporting設置爲E_ALL | E_STRICT(或者僅傳遞-1) –