php - 使用 php 将表单发送到我的电子邮件。提交表单时遇到 405 不允许的问题

标签 php html forms post nginx

从我创建的表单获取数据并通过 php 将其传递到我的电子邮件时遇到问题。这是表单 http://kapena.github.io/pp_web/#contact-pp 的链接

这就是确切的问题.. 当我单击表单按钮上的“提交”时,我收到此错误消息:.. error message

我目前在 gh-pages 上托管此版本

我对此做了一些研究,找到了错误 405 的补丁,但我不知道如何在我的项目中实现这个解决方案。我只是一个初学者,我需要一些指导..这是我找到的解决方案 https://gist.github.com/baskaran-md/e46cc25ccfac83f153bb#file-nginx-conf

如何在我的网站中正确实现此解决方案?
这是我的 php 代码,因此您可以检查它以查看是否存在导致此问题的问题。

如果有任何帮助,我们将不胜感激。尝试在新的一年推出 b4 :)

<?php
if($_POST["submit"]) {
$recipient = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6705150209131049100f0e130227000a060e0b4904080a" rel="noreferrer noopener nofollow">[email protected]</a>"; //my email
$subject = 'Email message from Point Plumbing';
$name = $_POST ["yourName"];
$email = $_POST["yourEmail"];
$phone = $_POST["yourPhone"];
$location = $_POST["yourLocate"];
$message = $_POST["message-me"];

$mailBody="Name: $name\nEmail: $email\n\n$message";
$mail($recipient, $subject, $mailBody, "From: $name <$email>");
$thankYou="<p>Thank you! We will be in contact with you shortly.</p>";
}
?>

我的 HTML..我感觉它与 method='post' 有关,可能这就是问题所在?

<form action="submit_form.php" method="post" id="spaceing" data-abide>
        <div class="form-bg">
            <div class="row">
                <div id="name" class="large-6 medium-6 small-12 columns">
                    <label> <h5>Name</h5>
                        <input type="text" name="yourName" placeholder="What is you're name?"></input>
                    </label>
                </div>

                <div id="email" class="large-6 medium-6 small-12 columns">
                    <label><h5>Email</h5>
                        <input type="email" name="yourEmail" placeholder="Please enter in you're email."required></input>
                    </label>
                    <small class="error">An email Address is required.</small>
                </div>
            </div>

                <div class="row">
                    <div id="phone"class="large-6 medium-6 small-12 columns">
                        <label><h5>Phone</h5>
                            <input type="text" name="yourPhone" placeholder="Please enter you're phone number."></input>
                        </label>
                    </div>

                    <div id="location" class="large-6 medium-6 small-12 columns">
                        <label><h5>Location</h5>
                            <input type="text" name="yourLocate" placeholder="Where on Oahu are you currently living?"></input>
                        </label>
                    </div>
                </div>

                <div class="row">
                    <div id="message-area" class="large-12 medium-12 small-12 columns">
                        <label><h5>Message</h5>
                            <textarea id="message" name="yourMessage" placeholder="Please tell us about you're plumbing issues."></textarea>
                        </label>
                    </div>
                </div>

            <div class="row">
                <div id="submit" class="large-3 medium-3 small-3 columns">
                    <button type="submit-me">Submit</button>
                </div>
            </div>
        </div>
    </form>

最佳答案

http://php.net/manual/en/function.mail.php

$mail($recipient, $subject, $mailBody, "From: $name <$email>");

$mail 不是变量,而是函数

mail($recipient, $subject, $mailBody, "From: $name <$email>");

关于php - 使用 php 将表单发送到我的电子邮件。提交表单时遇到 405 不允许的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27666234/

相关文章:

php - PHP 函数是否区分大小写,如果不是...?

php - 如何使用 jQuery 发送 JSON 对象数组

html - 表格单元格在连字符处换行

c# - 表单在 while 循环期间卡住

javascript - 如何为未选中的复选框分配值

ms-access - MS ACCESS---全部通过VBA刷新

php - 如何从 PHP 中的 json 响应中回显特定值

php - 找不到 Laravel 5.2 类,但类有命名空间

html - 百分比 'min-height' 仅当元素具有 'display: flex' 的间接父元素时才有效

html - CSS水平下拉