没有表格行动的cURL表格

时间:2016-12-10 06:01:21

标签: php forms curl form-submit

我正在尝试使用具有以下结构的curl提交表单(重要部分似乎没有表单操作,所以在PHP中我不知道如何发出将发送电子邮件的请求...... < / p>

那么如何在没有链接的情况下执行表单操作?如果它的某些形式的屏幕更新,这个方法会填充字段吗?                         

<div class="calendar-input">
<textarea class="contactFormMessage" placeholder="Message"></textarea>
<input id="emailListingsInline" class="primaryCheckbox emailListings"  checked="" type="checkbox">
<label class="emailListingsLabel" for="emailListingsInline">
<a class="primary contactFormAction" href="javascript:void(0);">

我已经查看了几个资源,感觉下面从http://www.html-form-guide.com/php-form/php-form-submit.html获取的代码是我需要的,我们称之为非安全形式......我稍微修改了它以匹配我的表单输入。

<?php
                //create array of data to be posted
                     $post_data['contactFormFirstName'] = 'name';
                     $post_data['contactFormLastName'] = 'lname';
                     $post_data['contactFormEmail'] = 'testemail';
                     $post_data['contactFormPhoneNumber'] = 'testnumber';
                     $post_data['contactFormDate'] = '01/01/2018';
                     $post_data['contactFormMessage'] = '';

               //traverse array and prepare data for posting (key1=value1)
                     foreach ( $post_data as $key => $value) {
                         $post_items[] = $key . '=' . $value;
                     }

                     //create the final string to be posted using implode()
                     $post_string = implode ('&', $post_items);

                     //create cURL connection
                     $curl_connection = 
                       curl_init('http://www.urlwithform.com/');

                     //set options
                     curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
                     curl_setopt($curl_connection, CURLOPT_USERAGENT, 
                       "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
                     curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
                     curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
                     curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);

                     //set data to be posted
                     curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);

                     //perform our request
                     $result = curl_exec($curl_connection);

                     //show information regarding the request
                     print_r(curl_getinfo($curl_connection));
                     print_r($post_string);
                     echo curl_errno($curl_connection) . '-' . 
                                     curl_error($curl_connection);

                     //close the connection
                     curl_close($curl_connection);
?>

我也可以看到请求响应,但似乎只是提交具有相同数据的帖子无法正常工作

{"ListingKey":"hx6mhk1","FirstName":"Test","LastName":"Tester","Email":"info@test.com","PhoneNumber" :"(817) 888-8888","MoveInDateTime":"01/01/2017","EmailListings":true,"Message":"","VisitId":"f8c9dfd9-ae1f-4df7-a2a3-346d771e335d" ,"VisitorId":"0a2eab79-6267-4483-9c78-e3cf9479f3e4","SiteId":1,"FrontDoor":"APTS","PageTypeId":32003 ,"PageTypeIdFrom":4005,"LeadTypeId":2}


Accept  
application/json, text/javascript, */*; q=0.01
Accept-Encoding 
gzip, deflate
Accept-Language 
en-US,en;q=0.5
Content-Length  
368
Content-Type    
application/json
Cookie  
"CRAZY COOKIE HERE"    
Host    
www.thesite.com
Referer 
http://www.thesiteurl.com/
User-Agent  
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0
X-Requested-With    
XMLHttpRequest

0 个答案:

没有答案
相关问题