【问题标题】:Bootstrap 4 form not sedning any messagesBootstrap 4表单不发送任何消息
【发布时间】:2019-09-23 05:00:21
【问题描述】:

我的 bootstrap 4 表单没有发送任何消息,我已经在服务器上上传了 index.php 和 contact.php 文件,但没有任何响应。你能帮我找出问题吗?

简单的登陆页面

<form id="#contacts" method="POST" class="form" role="form">
    <div class="row">
        <div class="col-md-6 form-group">
            <input class="form-control" id="name" name="name"
                   placeholder="Podaj swoje Imię i nazwisko" type="text" required/>
        </div>
        <div class="col-md-6 form-group">
            <input class="form-control" id="website" name="website"
                   placeholder="Adres strony www" type="text" required/>
        </div>
        <div class="col-md-6 form-group">
            <input class="form-control" id="telephone" name="telephone"
                   placeholder="Podaj swój numer telefonu" type="text" required/>
        </div>
        <div class="col-md-6 form-group">
            <input class="form-control" id="email" name="email"
                   placeholder="Podaj swój email" type="email" required/>
        </div>
    </div>
    <textarea class="form-control" id="message" name="message" placeholder="Twoja wiadomość"
              rows="4"></textarea>
    <br>
    <div class="row">
        <div class="col-md-12 form-group">
            <button class="btn btn-primary" type="submit">Wyślij</button>
        </div>
    </div>
</form>

contact.php

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$website = $_POST['website'];
$telephone = $_POST['telephone'];

$email_from = 'SEO';
$email_subject = 'Wiadomość kontaktowa z... '
$email_body = "Name: $name.\n".
              "Email: $email.\n".
              "Message: $message.\n";
              "Website: $website.\n";
              "Telephone: $telephone.\n";

$to = "biuro@of.pl";
$headers = "From: $email_from r\n";
$headers .= "Reply-To: $email r\n";

mail($to,$email-$email_subject,$email_body,$headers);

header("location: index.php");

?>

【问题讨论】:

    标签: php forms bootstrap-4


    【解决方案1】:

    您的表单丢失Action

    <form id="#contacts" method="POST" class="form" role="form" action="contact.php">
    

    【讨论】:

    • 但是我遇到了其他问题,整个页面会在 5 秒内自动刷新,你有什么想法可以阻止那个 mm
    • 您可能应该在另一个问题中发布...如果发生这种情况,我需要查看您的 javascript...如果我的回答对您有用,如果您能接受,那就太好了作为答案。谢谢。
    • 您好,代码中没有任何 javascript。以上就是你的全部了。
    猜你喜欢
    • 2022-10-31
    • 1970-01-01
    • 2016-06-11
    • 2014-04-30
    • 2020-01-07
    • 2018-09-08
    • 1970-01-01
    • 2012-03-25
    • 1970-01-01
    相关资源
    最近更新 更多