我的网站上有联系表,但是我很少有PHP经验。我能够发送电子邮件,但是有错误。我无法从下拉列表中选择要发送的电子邮件,文件附件不起作用,这些字段在我的电子邮件中显示为,名称:。除了显示“名字”的“名字字段”之外,任何帮助或指导都将不胜感激。
HTML:
<form name="secure" class="form-secure" action="contact.php"
method="POST" enctype="multipart/form-data" role="form">
<h4 class="secure-header pb-2 text-dark">Secure Email Form</h4>
<p class="text-secondary let-p font-italic">Please fill out
the form below to send your representative or department a
secure email</p>
<form class="form secure-email-form">
<div class="form-row">
<div class="form-group col-md-4 top-row">
<p><select name="recipient" id="recipient">
<option value="" class="form-control">Select Recipient *
</option>
<option
value="implementations@masspay.net">Implementation</option> .
<option
value="operations@masspay.net">Operations</option><option
value="tax@masspay.net">Tax</option><option
value="training@masspay.net">Training</option><option
value="sales@masspay.net">Sales</option><option
value="josh@masspay.net">Josh Soroko</option><option
value="jason@masspay.net">Jason Maxwell</option><option
value="jcarini@masspay.net">Jacklyn Carini</option><option
value="katie@masspay.net">Katie Rogers</option><option
value="jpowers@masspay.net">Jourdan Powers</option><option
value="brogers@masspay.net">Brittany Rogers</option><option
value="cflint@masspay.net">Charmaine Flint</option><option
value="knegron@masspay.net">Karina Negron</option><option
value="afox@masspay.net">Andrew Fox</option><option
value="paula@masspay.net">Paula Papalambros</option><option
value="mmcloy@masspay.net">Missy McLoy</option></select>
</p>
</div>
<div class="form-group col-md-6">
<p><input name="subject" id="subject" class="form-
control" type="text" placeholder="Subject *"></p>
</div>
</div>
<div class="form-group second-row">
<p><label><span class="attachment">Attachment </span>
<input name="fileMain" class="form-control" id="fileMain"
type="file"></label></p>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<p><input name="firstname" id="firstname"
class="form-control" type="text" placeholder="First Name *"></p>
</div>
<div class="form-group col-md-6">
<p><input name="lastname" id="lastname"
class="form-control" type="text" placeholder="Last Name *"></p>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<p><input name="email" type="text" class="form-
control" id="email" placeholder="Email *"></p>
</div>
<div class="form-group col-md-6">
<p><input name="emailC" type="text" class="form-
control" id="emailC" placeholder="Confirm Email *"></p>
</div>
</div>
<div class="form-group">
<p class="form-field organization">
<input type="text" value="" class="text email-
org form-control" size="56" maxlength="255" onchange="" .
placeholder="Organization">
</p>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<p><input name="phone" class="form-control" type="tel" value="" placeholder="Phone"></p>
</div>
<div class="form-group col-md-6">
<p>
<select name="stateSelect" id="state" class="form-control">
<option value="">Select Your State *</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
</select>
</p>
</div>
</div>
<div class="form-group">
<textarea class="form-control form-field mb-3" type="textarea" name="message" id="how-can-we-help-you" placeholder="How Can We Help You?" cols="55" rows="3"></textarea>
</div>
<div class="form-group">
<div class="prefered-contact">
<p>Prefered method of contact: <br>
<label class="mr-2">
<input name="contactmethod" id="contactmethod" class="form-control" type="radio" value="Phone"> Phone
</label>
<label>
<input name="contactmethod" class="form-control" id="contactmethod" type="radio" value="Email" checked="checked"> Email
</label>
</p>
</div>
</div>
<div class="form-group">
<p class="form-field %%form-field-css-classes%% pd-captcha required hidden %%form-field-dependency-css%%">
</p>
<div class="g-recaptcha" data-sitekey="6Lcw2H0UAAAAAPtObq6EBHb0JfBDaQcXcA1Esr-8"></div>
<p></p>
<div id="error_for_Recaptchapi_Recaptcha" style="display:none"></div>
</div>
<div class="form-group">
<input name="_utf8" type="hidden" value="☃">
<p class="submit submit-email">
<input type="submit" accesskey="s" value="Submit" class="submit-form">
</p>
</div>
<input type="hidden" name="hiddenDependentFields" id="hiddenDependentFields" value="">
</form>
</form>
php:
<?php
$name = $_POST['name'];
$subject = $_POST['subject'];
$fileMain = $_POST['fileMain'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$emailC = $_POST['emailC'];
$organization = $_POST['organization'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$email_from = 'MP Secure Email';
$email_subject = 'New Message From MP Secure Email';
$email_body = "Name: $name.\n".
"Subject: $name.\n".
"File: $fileMain.\n".
"First Name: $firstname.\n".
"Last Name: $lasttname.\n".
"Email: $email.\n".
"Email Confirm: $emailC.\n".
"Organization: $organization.\n".
"Phone: $phone.\n".
"Message: $message.\n";
$to ="mdonatelli@masspay.net";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $email \r\n";
mail($to,$email_subject,$email_body,$headers);
header("location: index.html");
if(isset($_POST['submit-form'])){
$selected_val = $_POST['recipient']; // Storing Selected Value In Variable
echo "You have selected :" .$selected_val; // Displaying Selected Value
}
if(isset($_POST['submit-form']) )
{
$varGender = $_POST['stateSelect'];
$errorMessage = "";
}
if (isset($_POST['submit-form'])) {
if(isset($_POST['radio']))
{
echo "You have selected :".$_POST['radio']; // Displaying Selected Value
}
}
?>