0

我在同一页面上有两个 php 表单现在问题是我通过 iframe 调用它们但是验证码不起作用,尽管我对具有不同输入字段的两个表单使用相同的脚本。现在发生的情况是,当我们第一次点击验证码并输入正确的验证码时,它会将我们带到您输入了错误的验证码,然后我们填写正确的验证码然后向我们显示谢谢...为什么当我们第一次输入时它不显示感谢正确的验证码??????

            <?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( "abc@gmail.com" );

                    $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);
                    }
                }
            }


            ?>
4

1 回答 1

1

验证码图像代码通常存储在会话变量中。当您显示第二个表单时,您将覆盖第一个表单的验证码。

于 2013-07-17T11:07:39.193 回答