我想在表单内容中显示$atendee_name
和$atendee_email
,但它不起作用,尽管它在另一节中有效。表单变量的回声不起作用
HTML代码:
<!-- RSVP section -->
<section id="rsvp">
<div class="rsvp-form-wrap">
<h2>RSVP</h2>
<p class="rsvp-desc"> WE'RE SO EXCITED TO CELEBRATE WITH YOU </p>
<form id="rsvp-form" action="sendmail.php" method="post" data-abide>
<div class="columns large-12">
<label for="atendee-name">Name (required)</label>
<input id="atendee-name" name="atendee_name" type="text" placeholder="John Doe" required pattern="[a-zA-Z]+">
<small class="error">Please enter your name.</small>
</div><!-- End .large-12 -->
<div class="columns large-12">
<label for="atendee-email">Email Address (required)</label>
<input id="atendee-email" name="atendee_email" type="email" placeholder="john[email protected]" required>
<small class="error">Please enter a valid email.</small>
</div><!-- End .large-12 -->
<div class="columns large-4 medium-4 small-4">
<label for="guests">Guests</label>
<select id="guests" name="guests">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div><!-- End .large-4 -->
<div class="columns large-8 medium-8 small-8">
<label for="attending">I am attending</label>
<select id="attending" name="attending">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</div><!-- End .large-8 -->
<div class="columns large-12">
<input id="rsvp-submit" class="button" type="submit" value="Submit" name="rsvp_submit">
</div><!-- End .large-12 -->
</form>
</div><!-- End .rsvp-form-wrap -->
</section><!-- End #rsvp -->
PHP代码:
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$name = $_POST['atendee_name'];
$email = $_POST['atendee_email'];
$guests = $_POST['guests'];
$attending = $_POST['attending'];
$formcontent="From: $name \n Attending: $attending \n Guests: $guests";
$recipient = "[email protected]";
$subject = "RSVP form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You! Message successfully sent.";
?>
错误:
Notice: Undefined index: atendee_name in /home/ayoudz/public_html/sendmail.php on line 5
Notice: Undefined index: atendee_email in /home/ayoudz/public_html/sendmail.php on line 6