简体   繁体   English

遇到PHP电子邮件提交表单的问题

[英]Having an issue with a PHP email submit form

You'll have to forgive me, Im self teaching PHP and new to all of this, but I am trying to create a simple PHP Email submit form and cant get the email or company fields to fill in on the email I get. 你将不得不原谅我,我自学PHP和所有这一切的新手,但我正在尝试创建一个简单的PHP电子邮件提交表单,并且无法获取电子邮件或公司字段以填写我收到的电子邮件。 I know its something easy I'm over looking, but I cant figure it out. 我知道它看起来很容易,但我无法弄明白。 Also, I need to find a way to put the senders email in the from area instead of the generic d91b8401@p3nlhg1156.shr.prod.phx3.secureserver.net that Im getting. 此外,我需要找到一种方法将发件人的电子邮件放在from区域而不是我得到的通用d91b8401@p3nlhg1156.shr.prod.phx3.secureserver.net。 Any help would be very appreciated. 任何帮助将非常感激。

<?php $name = $_POST['name'];
$email = $_POST['email'];
$company = $_POST['company'];
$message = $_POST['message'];
$formcontent="From: $name \nEmail: $email \nCompany: $company \nMessage: $message";
$recipient = "sales@pinnaclewebsitedesigns.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
?>

and here is the html 这是html

<form method="POST" action="send.php" class="contactForm">
                <div id="status"></div>
                <div class="contact_form">
                    <div class="row">
                        <div class="small-4 columns">
                            <input type="text" placeholder="Name" id="name" name="name" />
                        </div>
                        <div class="small-4 columns">
                            <input type="text" placeholder="E-mail" id="email" />
                        </div>
                        <div class="small-4 columns">
                            <input type="text" placeholder="Company" id="company" />
                        </div>
                        <div class="small-12 columns">
                            <textarea cols="10" rows="15" id="message" name="message"></textarea>
                        </div>
                        <div class="small-4 columns">
                            <input type="submit" class="button success right" value="Send message" name="send" id="send" />
                        </div> 
                    </div>
                </div>
                </form> 

You're missing the name attribute in your HTML. 您在HTML中缺少name属性。 Add that and you'll be good to go 添加它,你会很高兴

ie

<input type="text" placeholder="E-mail" name="email" id="email" />

you forgot to name your email and company form mate it should be 你忘记给你的电子邮件和公司形式的配对命名了

<input type="text" placeholder="E-mail" id="email"  name="email" />

and

<input type="text" placeholder="Company" id="company" name="company" />

enjoy coding :) 享受编码:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM