在发布给某人之前,我可以执行php吗? [英] How can I execute php before posting to someone elses script from a form?

查看:88
本文介绍了在发布给某人之前,我可以执行php吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个联系表单发送到mailchimp - 但在某些情况下,我也希望它发送一封电子邮件。

I have a contact form which posts to mailchimp - but in certain cases, I also want it to send out an email.

我认为更改了< form action =... 从mailchimp到我自己的页面,其中包含类似于以下内容:

I considered changing the <form action="... from mailchimp to my own page, containing something similar to the following:

<form action="mailchimp_url..." ...>

<? foreach($_POST as $name=>$value){?> 
    <input type="hidden" name="<? echo $name;?>" value="<? echo $value;?>"> 
<? }?> 

<? //mail the stuff I want somewhere else ?>

然后我可以使用javaScript自动执行这个pageload。

I could then just auto execute this on pageload with javaScript.

问题是,如果这样做,它将依赖于JavaScript,或者需要为用户添加一个按钮。

The Problem is, IF this works, it will be dependant on JavaScript, or will require an additional button click for the user.

有没有更优雅的方式来做到这一点

Is there a more elegant way to do this?

推荐答案

您可以先发布到自己的服务器

You can post to your own server first

<form action="your_path" ...>

然后使用 cURL 将相同的数据发送到mailchimp

Then use cURL to post the same data to mailchimp

以下是如何

这篇关于在发布给某人之前,我可以执行php吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆