为了账号安全,请及时绑定邮箱和手机立即绑定

表单输出空响应,并且不发送任何内容

表单输出空响应,并且不发送任何内容

PHP
尚方宝剑之说 2022-09-03 15:55:09
非常有必要使此表单从网站发送姓名和电话号码。当我尝试发送数据时 - 单击发送按钮后 - 我看到一个空的模式窗口而不是响应 - 发送或未发送。文件内容发送.php<?phpif ($_SERVER["REQUEST_METHOD"] == "POST") {    if (isset($_POST['name'])) {$name = $_POST['name'];}    if (isset($_POST['phone'])) {$phone = $_POST['phone'];}    $to = "recipient@gmail.com";    $sendfrom   = "sender@mail.ru";    $headers  = "From: " . strip_tags($sendfrom) . "\r\n";    $headers .= "Reply-To: ". strip_tags($sendfrom) . "\r\n";    $headers .= "MIME-Version: 1.0\r\n";    $headers .= "Content-Type: text/html;charset=utf-8 \r\n";    //$subject = "$formData";    $message = "<br><b>Имя пославшего:</b>". $name ."<br><b>Телефон:</b>". $phone;    $send = mail ($to, $headers, $message);    if ($send == 'true')    {        echo '<p class="success">Спасибо за отправку вашего сообщения!</p>';    } else {        echo '<p class="fail"><b>Ошибка. Сообщение не отправлено!</b></p>';    }} else {    http_response_code(403);    echo "Попробуйте еще раз";}?>
查看完整描述

2 回答

?
慕后森

TA贡献1802条经验 获得超5个赞

您在HTML中有两个嵌套表单,嵌套的HTML表单是不允许的,正如@Abdulla Nilam和HTML5的工作草案所提到的:

来自 html5 工作草案

4.10.3 表单元素

内容模型

流内容,但没有表单元素后代。

要使其工作,您应该删除第一个表单,因为它没有操作或方法:

<link rel="stylesheet" href="../css/feedback/remodal.css">

<link rel="stylesheet" href="../css/feedback/remodal-default-theme.css">

<a class="mainButton" href="#modal">Callback</a>


<div class="remodal" data-remodal-id="modal" role="dialog" aria-labelledby="modal1Title" aria-describedby="modal1Desc">

 <div class="remodalBorder">

  <button data-remodal-action="close" class="remodal-close" aria-label="Close"></button>

        <form id="form" action="../php/feedback/send.php" method="POST">

        <p><span class="formlable" style="text-transform: uppercase;">You name</span><br>

            <input type="text" class="putName" name="name"  cols="67%" placeholder="Required field" required>

        <p><span class="formlable" style="text-transform: uppercase;">Phone number</span><br>

            <input name="phone" type="tel" class="putPhone" placeholder="Required field" required>

            <input type="submit" name="submit" class="btn" value="Order a call">

            <input type="hidden" name="formData" value="Application from the site">

        <br><br>

By clicking on the "Order a call" button, you give <a class="mainArticlesTextAgree"  href="../agreement.html">consent to the processing of</a> your personal data.  

</div>

</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>

<script src="../js/feedback/remodal.min.js"></script>

<script src="../js/feedback/script.js"></script> 


查看完整回答
反对 回复 2022-09-03
?
慕田峪4524236

TA贡献1875条经验 获得超5个赞

试试这个HTML表单


<a class="mainButton" href="#modal">Callback</a>

<div class="remodal" data-remodal-id="modal" role="dialog" aria-labelledby="modal1Title" aria-describedby="modal1Desc">

  <div class="remodalBorder">

    <button data-remodal-action="close" class="remodal-close" aria-label="Close"></button>

    <form id="form" action="../php/feedback/send.php" method="POST">


      <p><span class="formlable" style="text-transform: uppercase;">You name</span><br>

        <input type="text" class="putName" name="name"  cols="67%" placeholder="Required field" required>

      </p>

      <p><span class="formlable" style="text-transform: uppercase;">Phone number</span><br>

        <input name="phone" type="tel" class="putPhone" placeholder="Required field" required>

        <input type="submit" name="submit" class="btn" value="Order a call">

        <input type="hidden" name="formData" value="Application from the site">

      </p>

      <br><br>

      By clicking on the "Order a call" button, you give <a class="mainArticlesTextAgree"  href="../agreement.html">consent to the processing of</a> your personal data.

    </form>

  </div>

</div>


查看完整回答
反对 回复 2022-09-03
  • 2 回答
  • 0 关注
  • 61 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信