<form role="form" action="./assets1/contact.php" method="post">
<div class="form-group">
<label for="c-form-name">
<span class="label-text">Name:</span>
<span class="contact-error"></span>
</label>
<input type="text" name="name" placeholder="Your name..." class="c-form-name form-control" id="c-form-name">
</div>
<div class="form-group">
<label for="c-form-email">
<span class="label-text">Email</span>
<span class="contact-error"></span>
</label>
<input type="text" name="email" placeholder="Your email address..." class="c-form-email form-control" id="c-form-email">
</div>
<div class="form-group">
<label for="c-form-phone">
<span class="label-text">Phone</span>
<span class="contact-error"></span>
</label>
<input type="text" name="phone" placeholder="Your phone number..." class="c-form-phone form-control" id="c-form-phone">
</div>
<div class="form-group">
<label for="c-form-artist">
<span class="label-text">Artist</span>
<span class="contact-error"></span>
</label>
<select name="artist" class="c-form-artist form-control" id="c-form-artist">
<option value="artist...">I would like to work with this artist...</option>
<option value="Amber">Amber</option>
<option value="Trinity">Trinity</option>
<option value="Maegan">Maegan</option>
<option value="Jason">Jason</option>
<option value="First Available">First Available</option>
</select>
</div>
<div class="form-group">
<label for="c-form-tattoo">
<span class="label-text">I would like to get...</span>
<span class="contact-error"></span>
</label>
<select name="get" class="c-form-get form-control" id="c-form-get">
<option value="get...">I would like to get...</option>
<option value="New Tattoo">A new tattoo</option>
<option value="Coverup">A coverup</option>
<option value="Addition">An addition to a existing tattoo</option>
</select>
</div>
<div class="form-group">
<label for="c-form-size">
<span class="label-text">I would like my tattoo to be this size...</span>
<span class="contact-error"></span>
</label>
<select name="size" class="c-form-size form-control" id="c-form-size">
<option value="4">4" or smaller</option>
<option value="palm">Palm Size</option>
<option value="grapefruit">Grapefruit or larger</option>
<option value="half">Half Sleeve</option>
<option value="full">Full Sleeve</option>
</select>
</div>
<div class="form-group">
<label for="c-form-budget">
<span class="label-text">My budget for this tattoo is...</span>
<span class="contact-error"></span>
</label>
<select name="budget" class="c-form-size form-budget" id="c-form-budget">
<option value="uncertain">Uncertain</option>
<option value="60-100">60-100</option>
<option value="100-300">100-300</option>
<option value="300-500">300-500</option>
</select>
</div>
<div class="form-group">
<label for="c-form-place">
<span class="label-text">I would like this tattoo placed on my...</span>
<span class="contact-error"></span>
</label>
<select name="placement" class="c-form-size form-placement" id="c-form-placement">
<option value="Arm">Arm</option>
<option value="Leg">Leg</option>
<option value="Shoulder Blade">Shoulder Blade</option>
<option value="Ribs">Ribs</option>
<option value="Foot">Foot</option>
<option value="Chest">Chest</option>
<option value="Other">Other</option>
</select>
</div>
<div class="form-group">
<label for="c-form-message">
<span class="label-text">Describe your ideal tattoo in detail. Please provide any reference you’d like me to consider via email @ <a href = "mailto: dearyoutattoo@gmail.com">DearYouTattoo@gmail.com</a> with your name and consult submittal date as the subject.</span>
<span class="contact-error"></span>
</label>
<textarea name="message" placeholder="Message text..." class="c-form-message form-control" id="c-form-message"></textarea>
</div>
<button onclick='return validateForm()' type="submit" class="btn">Send message</button>
</form>
/*
Contact form
*/
$('.c-form-box form').submit(function(e) {
e.preventDefault();
var this_form_parent = $(this).parents('.c-form-box');
var postdata = $(this).serialize();
$.ajax({
type: 'POST',
url: './assets1/contact.php',
data: postdata,
dataType: 'json',
success: function(json) {
$('.c-form-box form label[for="c-form-name"] .contact-error').fadeOut('fast', function(){
if(json.nameMessage != '') {
$(this).html('(' + json.nameMessage + ')').fadeIn('fast');
}
});
$('.c-form-box form label[for="c-form-email"] .contact-error').fadeOut('fast', function(){
if(json.emailMessage != '') {
$(this).html('(' + json.emailMessage + ')').fadeIn('fast');
}
});
$('.c-form-box form label[for="c-form-phone"] .contact-error').fadeOut('fast', function(){
if(json.professionMessage != '') {
$(this).html('(' + json.professionMessage + ')').fadeIn('fast');
}
});
$('.c-form-box form label[for="c-form-artist"] .contact-error').fadeOut('fast', function(){
if(json.subjectMessage != '') {
$(this).html('(' + json.subjectMessage + ')').fadeIn('fast');
}
});
$('.c-form-box form label[for="c-form-get"] .contact-error').fadeOut('fast', function(){
if(json.subjectMessage != '') {
$(this).html('(' + json.subjectMessage + ')').fadeIn('fast');
}
});
$('.c-form-box form label[for="c-form-size"] .contact-error').fadeOut('fast', function(){
if(json.subjectMessage != '') {
$(this).html('(' + json.subjectMessage + ')').fadeIn('fast');
}
});
$('.c-form-box form label[for="c-form-budget"] .contact-error').fadeOut('fast', function(){
if(json.subjectMessage != '') {
$(this).html('(' + json.subjectMessage + ')').fadeIn('fast');
}
});
$('.c-form-box form label[for="c-form-placement"] .contact-error').fadeOut('fast', function(){
if(json.subjectMessage != '') {
$(this).html('(' + json.subjectMessage + ')').fadeIn('fast');
}
});
$('.c-form-box form label[for="c-form-message"] .contact-error').fadeOut('fast', function(){
if(json.messageMessage != '') {
$(this).html('(' + json.messageMessage + ')').fadeIn('fast');
}
});
if(json.nameMessage == '' && json.emailMessage == '' && json.professionMessage == '' && json.subjectMessage == '' && json.messageMessage == '') {
this_form_parent.find('.c-form-top').fadeOut('fast');
this_form_parent.find('.c-form-bottom').fadeOut('fast', function() {
this_form_parent.append("<p>Thanks for contacting us! We will get back to you very soon.</p>");
// reload background
$('.c-form-container').backstretch("resize");
});
}
}
});
});
ts<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
// Email address verification
function isEmail($email) {
return filter_var($email, FILTER_VALIDATE_EMAIL);
}
if(isset($_POST['name'])){ $name = $_POST['name']; } {
// Enter the email where you want to receive the message
$emailTo = 'angeline.slayton@rocketmail.com';
$name = addslashes(trim($_POST['name']));
$clientEmail = addslashes(trim($_POST['email']));
$phone = addslashes(trim($_POST['phone']));
$artist = addslashes(trim($_POST['artist']));
$tat = addslashes(trim($_POST['tat']));
$size = addslashes(trim($_POST['size']));
$budget = addslashes(trim($_POST['budget']));
$placement = addslashes(trim($_POST['placement']));
$message = addslashes(trim($_POST['message']));
$array = array('nameMessage' => '',
'emailMessage' => '',
'phoneMessage' => '',
'artistMessage' => '',
'tatMessage' => '',
'sizeMessage' => '',
'budgetMessage' => '',
'placementMessage' => '',
'messageMessage' => ''
);
if($name == '') {
$array['nameMessage'] = 'Empty name!';
}
if(!isEmail($clientEmail)) {
$array['emailMessage'] = 'Invalid email!';
}
if($phone == 'Your phone...') {
$array['phoneMessage'] = 'Phone Number';
}
if($artist == 'Choose an artist...') {
$array['artistMessage'] = 'Choose an artist!';
}
if($tat == 'Choose a tattoo...') {
$array['tatMessage'] = 'Choose a tattoo!';
}
if($size == 'Choose a size...') {
$array['sizeMessage'] = 'Choose a size!';
}
if($budget == 'Choose a budget...') {
$array['budgetMessage'] = 'Choose a budget!';
}
if($placement == 'Choose a place...') {
$array['placementMessage'] = 'Choose a place!';
}
if($message == '') {
$array['messageMessage'] = 'Empty message!';
}
if($name!='' && isEmail($clientEmail) && $phone!='Your phone...'&& $artist!='Choose an artist...'&& $tat!='Choose a tattoo...' && $size!='Choose a size...'&& $budget!='Choose a budget...'&& $placement!='Choose a place...'&& $message!='') {
// Send email
$message = "Message from: " . $name . "\r\n" . "\r\n" . $message;
$headers = "From: " . $clientEmail . " <" . $clientEmail . ">" . "\r\n" . "Reply-To: " . $clientEmail;
mail($emailTo, $subject, $message, $headers);
}
echo json_encode($array);
}
?>
我正在建立包含多个下拉菜单的联系表。我是php新手。当我在表单上按Submit时,我收到未定义的变量错误,但未发送任何内容。
我尝试遍历代码并确保所有内容都匹配,但是我一定缺少一些东西。
ts
通知:未定义的索引:在第18行的/services/webpages/util/k/f/kfpoyr6o.attwebspace.com/dearyoutattoo.com/public/assets1/contact.php中,
注意:未定义的变量:第68行的/services/webpages/util/k/f/kfpoyr6o.attwebspace.com/dearyoutattoo.com/public/assets1/contact.php中的主题 {“ nameMessage”:“”,“ emailMessage”:“”,“ phoneMessage”:“”,“ artistMessage”:“”,“ tatMessage”:“”,“ sizeMessage”:“”,“ budgetMessage”:“”, “ placementMessage”:“”,“ messageMessage”:“”}