两个PHP表单在同一页面上

时间:2021-10-03 10:04:15

I have two php forms on same page now the problem is I am calling them through an iframe but there captcha is not working though I am using the same script for both the forms with different input fields. Right now what happens is when we click first time on captcha and write correct captcha it take us to YOU HAVE ENTERED WRONG CAPTCHA and then we fill correct captcha then show us thanku...Why not it shows thanks for the first time when we enter correct captch??????

我在同一页面上有两个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);
                    }
                }
            }


            ?>

1 个解决方案

#1


1  

A captcha image code is usually stored in a session variable. When you display the second form, you are overwriting the captcha from the first form.

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

#1


1  

A captcha image code is usually stored in a session variable. When you display the second form, you are overwriting the captcha from the first form.

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