提交外部表单,而无需离开页面/站点 - php

我浏览了该网站以寻找答案,但是没有找到我所需要的内容(这很接近,只是它实际上没有提交表单:Prevent form redirect OR refresh on submit?)。

我正在尝试将邮件列表注册(从ReverbNation托管的注册页面借来的代码)并入网站。

表单可以正确提交,但是签署人将被重定向到ReverbNation网站上一个丑陋的页面。我不能修改他们的脚本,也不认为可以使用API​​来保持整洁。

有没有一种方法可以在后台提交表单而无需重定向用户?

参考方案

这是PHP中用于传送POST的示例。

//set POST variables
$url = 'http://domain.com/url-to-post-to';
$fields = array(
            // Add the fields you want to pass through
            // Remove stripslashes if get_magic_quotes_gpc() returns 0.
            'last_name'=>urlencode(stripslashes($_POST['last_name'])),
            'first_name'=>urlencode(stripslashes($_POST['first_name'])),
            'email'=>urlencode(stripslashes($_POST['email']))
        );

//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string,'&');

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));

// returns the response as a string instead of printing it
curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);

//execute post
$result = curl_exec($ch);

//close connection
curl_close($ch);

echo $result;

PHP strtotime困境 - php

有人可以解释为什么这在我的服务器上输出为true吗?date_default_timezone_set('Europe/Bucharest'); var_dump( strtotime('29.03.2015 03:00', time()) === strtotime('29.03.2015 04:00�…

PHP-全局变量的性能和内存问题 - php

假设情况:我在php中运行一个复杂的站点,并且我使用了很多全局变量。我可以将变量存储在现有的全局范围内,例如$_REQUEST['userInfo'],$_REQUEST['foo']和$_REQUEST['bar']等,然后将许多不同的内容放入请求范围内(这将是适当的用法,因为这些数据指的是要求自…

php-casperjs获取内部文本 - php

我正在为casperjs使用php包装器-https://github.com/alwex/php-casperjs我正在网上自动化一些重复的工作,我需要访问一个项目的innerText,但是我尚不清楚如何从casperjs浏览器访问dom。我认为在js中我会var arr = document.querySelector('label.input…

PHP-从最后一个循环中删除逗号 - php

我在循环时有一个PHP,如果是最后一个循环,我想从,中删除​​最后一个逗号echo '],'; while($ltr = mysql_fetch_array($lt)){ echo '['; echo $ltr['days']. ' ,'. $ltr['name…

PHP Laravel从另一个驱动器读取文件 - php

我目前正在学习Laravel。我想知道是否有一种方法可以在Laravel中使用Storage::从另一个硬盘访问文件(使用Windows)。例如,我在驱动器C:上安装了带有Laravel的Xampp,但是我想访问网站目录之外的E:上的文件。我试过使用Storage::files('E:')和File::files('E:…