2013-07-17 29 views
0

我在同一頁面上有兩個php表單,現在問題是我通過iframe調用它們,但是captcha沒有工作,雖然我對不同輸入字段的表單使用相同的腳本。現在會發生什麼,當我們點擊第一次驗證碼並寫入正確的驗證碼時,我們會向您輸入錯誤的驗證碼,然後我們填寫正確的驗證碼,然後向我們顯示thanku ...爲什麼不顯示第一次當我們輸入正確的captch ??????在同一頁面上的兩個PHP表格

  <?php 
      session_start(); 
      $tuCurl = curl_init(); 
      curl_setopt($tuCurl, CURLOPT_URL, $url); 
      curl_setopt($tuCurl, CURLOPT_RETURNTRANSFER, 1);  
      $tuData = curl_exec($tuCurl); 
      curl_close($tuCurl); 
      $userip = explode(',',$tuData); 
      $ipcountry = str_replace('"', '', $userip[3]); 

      include "libmail.php"; 
      $errors = ''; 
      //print_r($_POST); 
      if(isset($_POST['email'])) 
      { 
       if(empty($_SESSION['6_letters_code']) || 
        strcasecmp($_SESSION['6_letters_code'], $_POST['captcha']) != 0) 
       { 
        $errors .= "You have entered wrong captcha code!"; 
       }elseif($_FILES["userfile"]["size"] > 1048576) 
       { 
        $errors .= "You can upload maximum of 800kb file!"; 
       }else{ 

         $productsq  = $_POST['productsq']; 
        $name  = $_POST['name']; 
        $position  = $_POST['position']; 
        $phone  = $_POST['phone']; 

        $company = $_POST['company']; 
        $companyweb = $_POST['companyweb']; 
        $address = $_POST['address']; 
        $country = $_POST['country']; 
            $brief  = $_POST['brief']; 
        $email  = $_POST['email']; 


        $captcha = $_POST['captcha']; 

        $sender = $contact_email; 

        function clean_string($string) { 
         $bad = array("content-type","bcc:","to:","cc:","href"); 
         return str_replace($bad,"",$string); 
        } 

        if(trim($productsq) !='') 
         $email_message .= "*I'm interested in : ".clean_string($productsq)."\n"."\n"; 

        if(trim($name) !='') 
         $email_message .= "Full Name: ".clean_string($name)."\n"."\n"; 

           if(trim($position) !='') 
         $email_message .= "Position/Title: ".clean_string($position)."\n"."\n"; 

              if(trim($phone) !='') 
         $email_message .= "Phone: ".clean_string($phone)."\n"."\n"; 

        if(trim($company) !='') 
         $email_message .= "Company Name: ".clean_string($company)."\n"."\n"; 

         if(trim($companyweb) !='') 
         $email_message .= "Website URL: ".clean_string($companyweb)."\n"."\n"; 


        if(trim($address) !='') 
         $email_message .= "Full Address: ".clean_string($address)."\n"."\n"; 


        if(trim($country) !='') 
         $email_message .= "Country: ".clean_string($country)." (IP Address) : $ipcountry ".$_SERVER['REMOTE_ADDR']."\n"."\n"; 



        if(trim($brief) !='') 
         $email_message .= "About Myself : ".clean_string($brief)."\n"."\n"; 

        $random = mt_rand(); 
        $m= new Mail; // create the mail 
        $m->From($name."<$email>"); 
        $m->To("[email protected]"); 

        $m->Subject("Form2 - ".$random); 

        $m->Body($email_message); 
        $m->Priority(2) ; 

        if($_FILES["userfile"]["tmp_name"]){ 
         move_uploaded_file($_FILES["userfile"]["tmp_name"], 'uploadedfiles/'.$_FILES["userfile"]["name"]); 
         $file_upload = 'uploadedfiles/'.$_FILES["userfile"]["name"]; 
         $m->Attach($file_upload) ; 
        } 
        $m->Send(); 
       header('location:thankyou.php'); 
        if($_FILES["userfile"]["tmp_name"]){ 
         unlink($file_upload); 
        } 
       } 
      } 


      ?> 

回答

1

驗證碼圖像碼通常存儲在會話變量中。當您顯示第二個表單時,您將覆蓋第一個表單中的驗證碼。

+0

那麼先生你可以建議我該怎麼做?實際上m不知道php代碼太多pls先生 –

+0

要麼在同一頁面上使用2個驗證碼,要麼在會話中給它們不同的名稱。 – Rob

+0

嘗試用不同的變量名captca爲這兩種形式 –

相關問題