我希望客户从下拉列表中选择不同的选项,然后在提交表单后在电子邮件中显示所选选项。它应该发送电子邮件给我和客户。现在它不是从选择中发送值。
我有以下代码:
<?php
if(isset($_POST['submit'])){
$to = "myemail@myemail.com"; // this is your Email address
$from = $_POST['email_address']; // this is the sender's Email address
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$address_street = $_POST['address_street'];
$phone = $_POST['phone_no'];
$quantity = $_POST['quantity'];
$select = $_POST['select'];
$subject = "Write the subject here";
$subject2 = "Write the subject here";
$message = "You have selected:" . "\n\n" . "" . $phone . $_POST['quantity'] . $_POST['select'] . $_POST['address_street'];
$message2 = "you have selected:" . "\n\n" . "" . $_POST['quantity'] . $_POST['select'] . $_POST['address_street'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo "Din mail er sendt " . $first_name . " " . $last_name . " " . ". Du har valgt følgende vinduer: " . $select;
}
?>
<form action="" method="POST">
<div class="row">
<div class="large-3 medium-6 small-12 columns">
<img class="windows" src="http://spejlblank.nu/wp-content/uploads/2016/03/SPEJLBLANK_INTERIOR_V036_ENKELTFAG.jpg" width="385" height="385" alt="">
<div class="dropdown-option">
<select id="select" name="select">
<option value="" selected>VÆLG POLERINGSTYPE</option>
<option value="30">INDVENDIG + UDVENDIG</option>
<option value="60">UDVENDIG</option>
<option value="90">INDVENDIG</option>
<option value="90">FORSATS (INKL. INDVENDIG + UDVENDIG)</option>
</select>
</div>
<div class="quantity-field">
<input type="number" name="quantity" min="0" max="100" placeholder="STK.">
</div>
</div>
<div class="row contact-form-pris">
<h3 style="text-transform: uppercase;">Indtast dine oplysninger og modtag dit uforpligtende tilbud!</h3>
<div class="large-6 small-12 columns">
<label for="first_name">Fornavn *</label>
<input class="" name="first_name" id="first_name" type="text" required/>
</div>
<div class="large-6 small-12 columns">
<label for="last_name">Efternavn *</label>
<input class="" name="last_name" id="last_name" type="text" required/>
</div>
<div class="large-12 columns">
<label for="address_street">Adresse *</label>
<input class="" name="address_street" id="address_street" type="text" required/>
</div>
<div class="large-6 small-12 columns">
<label for="email_address">Email *</label>
<input class="" name="email_address" id="email_address" type="email" required/>
</div>
<div class="large-6 small-12 columns">
<label for="mobile_no">Telefon *</label>
<input class="" name="mobile_no" id="mobile_no" type="tel" required/>
</div>
<div class="large-12 columns text-center">
<input type="submit" name="submit" value="MODTAG UFORPLIGTENDE TILBUD" class="submit-pris">
</div>
</div>
</form>
答案 0 :(得分:1)
在下拉列表中尝试此操作
<select id="select" name="select">
<option value="VÆLG POLERINGSTYPE" selected>VÆLG POLERINGSTYPE</option>
<option value="INDVENDIG + UDVENDIG">INDVENDIG + UDVENDIG</option>
<option value="UDVENDIG">UDVENDIG</option>
<option value="INDVENDIG">INDVENDIG</option>
<option value="FORSATS (INKL. INDVENDIG + UDVENDIG)">FORSATS (INKL. INDVENDIG + UDVENDIG)</option>
</select>
在您的第一个选项中,您发送了空白值,其他值是您可能不希望显示的数字,以使电子邮件变得有意义。
答案 1 :(得分:0)
更改
<option value="" >VÆLG POLERINGSTYPE</option>
到
{{1}}