我有自己的表单,可以向两封电子邮件发送消息。它正在发挥作用。
我想将$ _ [POST]中的相同数据保存到Google文档。
如何将数据发送到2封电子邮件和Google电子表格?
HTML code:
<form role="form" action="mail.php" method="post">
<input type="text" name="company" id="company" class="form-control" placeholder="Your company">
<input type="text" name="city" id="city" class="form-control" placeholder="City">
<input type="text" name="person" id="person" class="form-control" placeholder="Name and surname">
<input type="tel" name="phone" id="phone" class="form-control" placeholder="Phone number">
<input type="email" name="email" id="email" class="form-control" placeholder="E-mail">
<button type="submit" id="submit-btn" class="btn btn-default">Submit</button>
</form>
mail.php
<?php
$to = 'user1@domain.com, user2@domain.com';
$subject = 'email from domain.com';
$company = $_POST['company'];
$city = $_POST['city'];
$person = $_POST['person'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$message = '<b>Message from website</b>'. "\r\n". "<br>" .
'<b>Company:</b> '. $company . "\r\n". "<br>" .
'<b>City:</b> '. $city . "\r\n". "<br>" .
'<b>Person:</b> '. $person . "\r\n". "<br>" .
'<b>Phone:</b> '. $phone . "\r\n" . "<br>" .
'<b>Email:</b> '. $email . "\r\n";
$headers = 'From: ' . 'companies@domain.com' . "\r\n" .
'Content-type: text/html; charset=utf-8';
mail($to, $subject, $message, $headers);
echo "Thank You, your email has been sent!<br />";
include 'success.php';
?>
我看到我可以创建谷歌表单并替换我的表单,但这样我只能将数据保存到电子表格,而不发送电子邮件。
我如何结合这两种功能?
感谢所有提示。