我一直在尝试多种方式将输入的电子邮件地址输入到表单中:http://contest.realfamilytrips.com保存到某种文件中。我没有运气。现在,我正在尝试通过电子邮件向每个条目发送电子邮件,并且没有太多运气。
我整理了一些PHP代码(经过几个小时的研究。我对这一事情很新),每次用户在表单中输入他们的电子邮件地址时都应该给我发电子邮件,但它不是工作。
这是一个单页目标网页,因此没有大量代码。我想分享index.html和我的php脚本,以及stylesheet和functions.js文件。如果有人可以告诉我如何保存或通过电子邮件发送这些电子邮件地址,或者我会非常感激。
的index.html:
<!DOCTYPE html>
<html lang="en-US" xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head>
<title>iPad Air Giveaway</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="css/images/favicon.ico" />
<link rel="stylesheet" href="css/style.css" type="text/css" media="all" />
<link rel="stylesheet" href="css/video-js.css" type="text/css" media="all" />
<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="js/html5.js" type="text/javascript"></script>
<script src="js/functions.js" type="text/javascript"></script>
<link rel="shortcut icon" href="favicon.ico" >
<link rel="icon" type="image/gif" href="animated_favicon1.gif" >
</head>
<body class="type-3">
<p></p>
<!-- Shell -->
<div class="shell"><!-- Sidebar --> <aside id="sidebar">
<div class="item"><img src="css/images/ipadgraphic.png" alt="win an ipad air" /></div>
<p style="text-align: left;">Enter sweepstakes to win a brand new iPad Air. Unsubscribe<br /> anytime. <a href="http://realfamilytrips.com/real-family-trips-great-family-itinerary-contest-terms-conditions/">Click here for official terms and conditions</a></p>
</aside> <!-- END Sidebar --> <!-- Content --><section id="content"><!-- Logo -->
<h1 id="logo"><a href="http://realfamilytrips.com" title="home">Real Family Trips</a></h1>
<div>
<h2>Win an iPad Air</h2>
<h2 class="pull-up">For The Best Family Itinerary</h2>
<p style="text-align: left;" class="intro-text"><em>Hey there World Traveler!</em></p>
<p style="text-align: left;" class="intro-text"><em>Want to win an <span class="largetext">iPad Air</span> in a contest for the best family itinerary? Start by answering the question below. You can also share this with others, so more families can learn how to travel with their kids for the best experience!<span size="-1"><a href="http://realfamilytrips.com/real-family-trips-great-family-itinerary-contest-helpful-hints/" style="text-decoration: none; border-bottom: 1px solid #095DF7;"> more details</a></span></em></p>
<!-- Step 1 -->
<div class="steps step-1">
<h2 style="font-size: 26px;">STEP 1: Answer this question</h2>
<form action="#" method="post">
<div class="select-holder"><label>Who is giving away a new 7.5" retina display iPad Air?</label>
<div class="select-wrap"><select name=""> <option selected="selected" value="Select Your Answer">Select Your Answer</option> <option value="LeadBrite, Duh!">RealFamilyTrips, hello...</option> <option value="Lady Gaga">My next door neighbor</option> <option value="Santa Claus">Santa Claus</option> </select></div>
</div>
<input value="Submit Answer " class="submit-button" type="submit" /></form>
<div class="contest-ends">
<p><span>Contest Ends</span></p>
<p>January 31st, 2014 2:00 pm E.S.T.</p>
</div>
</div>
<!-- END Step 1 -->
<!-- Step 2 -->
<div class="steps step-2">
<h2 style="font-size: 26px;">STEP 2: Your details</h2>
<form action="signup.php" method="post" name="emailaddy">
<input type="text" class="field" value="Enter your email address" title="Enter your email address" />
<input type="submit" value="Send" class="send" />
</form>
<div class="contest-ends">
<p><span>Contest Ends</span></p>
<p>January 31st, 2014 2:00 pm E.S.T.</p>
</div>
</div>
<!-- END Step 2 -->
<!-- Step 3 -->
<div class="steps step-3">
<h2 style="font-size: 26px;">STEP 3: Submit Itinerary</h2>
<a href="http://realfamilytrips.com/share-itineraries"> <input value="Go!" class="send" type="submit" /> </a>
<div class="contest-ends">
<p><span>Contest Ends</span></p>
<p>January 31st, 2014 2:00 pm E.S.T.</p>
</div>
</div>
<!-- END Step 3 -->
<p class="inspired">brought to you by <a href="http://realfamilytrips.com">Real Family Trips</a></p>
</div>
</section><!-- END Content -->
<div class="cl"> </div>
</div>
<!-- END Shell -->
<p></p>
</body>
</html>
SIGNUP.php:
<?php
/* Subject and Email variables */
$emailSubject = 'Real Family Trips Contest';
$webmaster = lifeleavesscars@gmail.com
/* Gathering Data Variables */
$emailField = $_POST['emailaddy'];
$body = <<<EOD
<br><hr><br>
Email address: $email <br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail ($webmaster, $emailSubject, $body, $headers);
?>
的style.css:
@import url('fonts.css');
* { margin: 0; padding: 0; outline: 0; }
body, html { height: 100%; }
body {
font-size: 18px;
line-height: 24px;
font-family: 'SegoeUI', arial, sans-serif;
color: #314b7b;
background: #fff url(images/body1.png) repeat-y center 0;
min-width: 980px;
}
a { color: #0252aa; text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }
a img { border: 0; }
em { font-style: normal; font-family: 'SegoeUI-Italic'; }
.largetext { font-size:150%; font-weight:bold; }
input, textarea, select { font-size: 18px; font-family: 'SegoeUI', arial, sans-serif; }
textarea { overflow: auto; }
select { background:none repeat scroll 0 0 transparent; border: 0; font-family: 'SegoeUI'; font-size: 14px; line-height: 24px; width: 367px; -webkit-appearance: menulist; margin: 0 5px 0 4px; }
.cl { display: block; height: 0; font-size: 0; line-height: 0; text-indent: -4000px; clear: both; }
.notext { font-size: 0; line-height: 0; text-indent: -4000px; }
.left, .alignleft { float: left; display: inline; }
.right, .alignright { float: right; display: inline; }
h2 { font-family: 'SegoeUI-Bold'; font-size: 30px; line-height: 36px; color: #314b7b; text-align:center; font-weight: normal; }
h2 span { font-size: 36px; display: block; padding-bottom: 2px; }
.shell { width: 960px; margin: 0 auto; }
#logo { width: 289px; margin: 0 auto; font-size: 0; line-height: 0; padding-bottom: 14px; }
#logo a { display: block; width: 289px; height: 62px; background: url(images/logo.png) no-repeat 0 0; text-indent: -4000px; }
#sidebar { display: inline; float: left; width: 503px; padding-top: 32px; }
#sidebar h2 { width: 380px; margin: 0 auto; margin-top: 30px; }
#content { display: inline; float: right; padding: 27px 13px 0 11px; width: 415px; }
#content h2 { color: #010101; text-shadow: 0 1px #fff; padding-right: 6px; letter-spacing: -1px; }
#content h2.pull-up { position: relative; margin-top: -6px; padding-bottom: 17px; }
#content p.intro-text { width: 372px; margin: 0 auto; text-align:center; padding: 0 0 9px 24px; }
#content p.inspired { font-size: 15px; text-align:center; color: #8f8f8f; text-shadow: 1px 2px 1px #f6f6f6 }
#content p.inspired a { color: #8f8f8f; text-decoration: underline; }
#content p.inspired a:hover { text-decoration: none; }
.steps { padding-bottom: 29px; }
.steps p { font-size: 20px; line-height: 30px; color: #010101; width: auto; text-align:center; }
.steps form label { display: block; padding-bottom: 23px; }
.steps form p a { color: #015978; text-decoration: underline; }
.steps form p a:hover { text-decoration: none; }
.steps form .select-holder { margin-top: 7px; padding: 13px 19px 20px 13px; background: #fff; }
.steps .select-wrap { width: 375px; border: solid 1px #707070; padding: 2px 0 4px 0; margin-left: 1px; }
.steps .submit-button { display: block; width: 346px; height: 73px; margin: 16px auto 0; background: url(images/submit-button.png) no-repeat 0 0; border: 0; }
.steps .submit-button { font-family: 'SegoeUI-Bold'; font-size: 30px; color: #212121; cursor: pointer; text-shadow: 0 1px #faf562; letter-spacing: -1px; }
.steps .submit-button:hover { background-position: 0 -73px; }
.steps .send { display: block; width: 346px; height: 73px; margin: 16px auto 0; background: url(images/send.png) no-repeat 0 0; border: 0;}
.steps .send { font-family: 'SegoeUI-Bold'; font-size: 30px; color: #212121; cursor: pointer; text-shadow: 0 1px #faf562; letter-spacing: -1px; }
.steps .send:hover { background-position: 0 -73px; }
.steps .field { margin: 25px 0 17px 6px; padding: 10px 20px 11px; line-height: 28px; width: 366px; box-shadow: inset 3px 5px 3px 3px #f5f5f5; background: #fff; border: solid 1px #d7d7d7; }
.step-2 { display: none; }
.step-3 { display: none; }
.contest-ends { padding-top: 16px; }
.contest-ends p { font-size: 20px; line-height: 24px; color: #8f8f8f; text-shadow: 0 1px #fff; text-align:center; }
.contest-ends p span { display: block; line-height: 18px; font-size: 15px; }
body.type-2 { background: #e1e1e1 url(images/body2.png) repeat-x 0 0; }
body.type-2 #wrapper { background: url(images/wrapper.jpg) no-repeat center 0; }
body.type-2 #logo { width: 365px; }
body.type-2 #logo a { width: 365px; height: 62px; background: url(images/logo2.png) no-repeat 0 0; }
body.type-2 .steps p { color: #fff; }
body.type-2 #sidebar h2 { margin-top: 10px; width: auto; color: #2e0035; }
body.type-2 #content p.intro-text { font-family: 'MuseoSlab-500'; font-size: 24px; line-height: 30px; width: auto; padding: 2px 0 16px 0; color: #2e0035; }
body.type-2 .select-holder { margin-left: 2px; }
body.type-2 .select-holder label { padding-bottom: 13px; }
body.type-2 .submit-button { margin-top: 23px; }
body.type-3 { background: #fff url(images/body3.png) repeat-y center 0; }
body.type-3 .shell { width: 874px; }
body.type-3 #logo { padding-bottom: 19px; }
body.type-3 #sidebar { padding-top: 29px; width: 354px; }
body.type-3 #sidebar h2 { padding: 0 0 42px 0; margin-top: 9px; width: 280px; }
body.type-3 #content { width: 495px; }
body.type-3 #content h2.pull-up { padding-bottom: 22px; }
body.type-3 #content p.intro-text { padding: 0 0 27px 10px; width: 433px; }
body.type-3 .steps p { letter-spacing: 1px; }
body.type-3 .select-holder { margin: 16px 30px 0 35px; padding: 13px 19px 20px 18px; }
body.type-3 .submit-button { margin-top: 29px; }
body.type-3 .contest-ends { padding-top: 12px; }
body.type-3 .field { margin: 20px 0 17px 47px; }
body.type-3 #sidebar p { font-size: 12px; line-height: 18px; color: #666666; text-align:center; padding-right: 14px; padding-left: 14px; }
body.type-3 #sidebar p a { color: #666; text-decoration: underline; }
body.type-3 #sidebar p a:hover { text-decoration: none; }
#mc_embed_signup{ font:14px Helvetica,Arial,sans-serif; text-align: center; }
FUNCTIONS.js
$(function () {
$(document).on('focusin', '.field, textarea', function () {
if (this.title == this.value) {
this.value = '';
}
}).on('focusout', '.field, textarea', function () {
if (this.value === '') {
this.value = this.title;
}
});
$(document).on('click', '.submit-button', function () {
if ($('select').find('option:selected').index() === 0) {
alert('Select Your Answer.');
return false;
}
if ($('select').find('option:selected').index() !== 1) {
alert('Your guess is wrong! Please try again.');
return false;
} else {
$('.step-1').hide();
$('.step-2').fadeIn(800);
return false;
}
});
$(document).on('submit', 'form', function (e) {
// Check email address
// if email address ok
$('.step-2').hide();
$('.step-3').fadeIn(800);
e.preventDefault();
// else
// alert
// e.preventDefault();
// end if
});
});
感谢并抱歉所有代码。我不知道是否需要它,但经过这么多天的尝试,我想也许jquery搞乱了PHP?不确定。此时我不知道。
提前致谢。
答案 0 :(得分:0)
您的表单标记不正确。当您将form
元素放在输入上时,您将为name
元素提供<form action="signup.php" method="post">
<input type="text" class="field" name="emailaddy" value="Enter your email address" title="Enter your email address" />
<input type="submit" value="Send" class="send" />
</form>
属性。正确的标记:
$webmaster = lifeleavesscars@gmail.com
此外,在您的PHP文件中,此行不正确:Request Url: http://contest.realfamilytrips.com/signup.php
Request Method: POST
Status Code: 200
Params: {
"emailaddy": "test@test.com"
}
Status Code: 200
Date: Wed, 01 Jan 2014 00:43:01 GMT
Content-Encoding: gzip
Server: Apache
Vary: Accept-Encoding
Content-Type: text/html
Connection: Keep-Alive
Keep-Alive: timeout=5, max=100
Content-Length: 24
。你缺少引号和分号。
如果它仍然无法正常工作,您是否收到了电子邮件,是否只是缺少用户的电子邮件地址,或者是什么?
我尝试POST到您的PHP文件并获得200 ok响应并且没有看到任何错误,是否启用了错误报告?
{{1}}
执行此操作的最佳方法是将电子邮件地址保存到数据库中。