简体   繁体   中英

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. 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. 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

<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. 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 :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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