只是一些字段从我的html通过我的register.php发布到我的电子邮件

时间:2016-03-21 03:16:19

标签: php html email

我似乎无法在我的html中获取其他字段以通过我的register.php文件发布

这是我在电子邮件中收到的内容:它只是发布电子邮件地址而不是其他字段的姓名,电话和保险。

名字:(不显示) 姓氏:(不显示) 电子邮件:myemail@myemail.com(仅显示字段) 电话:(没有出现) 保险:(没有出现)

任何人都可以帮我解决我的看法吗?

<form role="form" action="register.php" method="post" enctype="plain"> <input name="email" class="subscribe-input" placeholder="Enter your e-mail address..." required="yes" type="email script type="text/javascript">,<input name="name" class="subscribe2-input" placeholder="First Name" required="yes" type="email script type="text/javascript">,<input name="surname" class="subscribe3-input" placeholder="Last Name" required="yes" type="email script type =&#34; text / javascript&#34;&gt;,{{ 1}} <input name="phone" class="subscribe4-input"类型=&#34; text / javascript&#34;&gt;,placeholder="Phone" required="yes" type="email script <input name="insurance" class="subscribe5-input" placeholder="Do You Have A Life License" required="yes" type="email script type="text/javascript"><button class="btn btn-lg btn-download subscribe-submit"

type="submit">Learn More</button><script type="text/javascript">

2 个答案:

答案 0 :(得分:0)

至少将设计与逻辑分开。

<强> register_process.php

<?php

if (count($_POST)) {

    $field_email = $_POST['email'];
    $field_name = $_POST['name'];
    $field_surname = $_POST['surname'];
    $field_phone = $_POST['phone'];
    $field_insurance = $_POST['insurance'];

    $mail_to = 'info@teamworktowealth.com';
    $subject = 'Message from a site visitor '.$field_email;

    $body_message = 'First Name: '.$field_name."\n";
    $body_message .= 'Last Name: '.$field_surname."\n";
    $body_message .= 'E-mail: '.$field_email."\n";
    $body_message .= 'Phone: '.$field_phone."\n";
    $body_message .= 'Insurance: '.$field_insurance."\n";

    $headers = 'From: '.$field_email."\r\n";
    $headers .= 'Reply-To: '.$field_email."\r\n";

    $mail_status = mail($mail_to, $subject, $body_message, $headers);

}

<强> register.php

<?php include 'register_process.php'; ?>
<html>
    <body>

    <!-- all your form elements go here -->

    <?php if (count($_POST)): ?>
        <?php if ($mail_status): ?>
            <script language="javascript" type="text/javascript">
               window.location.href ='http://www.thankyou.fidelisinsurancecompany.com';
            </script>
        <?php else: ?>
            <script language="javascript" type="text/javascript">
                alert('Registration failed. Please, send an email to info@fidelisltd.com');
                window.location = 'http://www.fidelisinsurancecompany.com';
            </script>
        <?php endif; ?>
    <?php endif; ?>
    </body>
</html>

答案 1 :(得分:0)

您真的需要格式化代码并使其可读。不得不将其复制出来以查看问题。这是您当前的表单输入

<input name="email" class="subscribe-input" placeholder="Enter your e-mail address..." required="yes" type="email script type="text/javascript",input name="name" class="subscribe2-input" placeholder="First Name" required="yes" type="email script type="text/javascript",input name="surname" class="subscribe3-input" placeholder="Last Name" required="yes" type="email script type="text/javascript",input name="phone" class="subscribe4-input" placeholder="Phone" required="yes" type="email script type="text/javascript",input name="insurance" class="subscribe5-input" placeholder="Do You Have A Life License" required="yes" type="email script type="text/javascript"><button class="btn btn-lg btn-download subscribe-submit" type="submit">Learn More</button>

您缺少很多关闭引号和结束标记。这是一个修复

<input name="email" class="subscribe-input" placeholder="Enter your e-mail address..." required="yes" type="email">
<input name="name" class="subscribe2-input" placeholder="First Name" required="yes" type="text">
<input name="surname" class="subscribe3-input" placeholder="Last Name" required="yes" type="text">
<input name="phone" class="subscribe4-input" placeholder="Phone" required="yes" type="text">
<input name="insurance" class="subscribe5-input" placeholder="Do You Have A Life License" required="yes" type="text">
<button class="btn btn-lg btn-download subscribe-submit" type="submit">Learn More</button>

您的代码也需要自己修复...尽可能分离逻辑,关闭引号和标记。