我试图通过表单发送一些信息(来自PageLanes的Minimal Form),这有一些问题,我希望用户回答它们。
答疑部分已完成(www.wemadeyou.pt/formulario),但我无法将问题与用户答案一起发送到我的电子邮箱。
以下是代码:
HTML
<form method="post" id="theForm" class="simform animated fadeIn" autocomplete="off" action="send.php" name="form">
<div class="simform-inner">
<ol class="questions">
<li> <span><label for="q1">Digita o teu nome, idade e localização: (Ex.: Wilson Fonseca, 23, Barreiro/Lisboa)</label></span>
<input id="q1" name="q1" type="text" tabindex="3" />
</li>
<li> <span><label for="q2">Qual é a tua área? (Front-End Development, Back-End, Webdesigner, Marketing, UI/UX Design ou Graphic Design)</label></span>
<input id="q2" name="q2" type="text" />
</li>
<li> <span><label for="q3">Porque concorres a uma posição neste projecto?</label></span>
<input id="q3" name="q3" type="text" />
</li>
<li> <span><label for="q4">Tens algum tipo de formação na área? (Escola, curso ou tutorials/autodidata)</label></span>
<input id="q4" name="q4" type="text" />
</li>
<li> <span><label for="q5">Tens alguma experiência anterior? Se sim, descreve.</label></span>
<input id="q5" name="q5" type="text" />
</li>
<li> <span><label for="q6">Sabes programar em que línguas? (Se não sabes, escreve “-”)</label></span>
<input id="q6" name="q6" type="text" />
</li>
<li> <span><label for="q7">Qual é a tua capacidade com Photoshop (Básica, Mediana, Boa, Im the King of the World!)</label></span>
<input id="q7" name="q7" type="text" />
</li>
<li> <span><label for="q8">Consideraste uma pessoa criativa? Achas que tens o perfil indicado para um projecto de longo termo? Porquê?</label></span>
<input id="q8" name="q8" type="text" />
</li>
<li> <span><label for="q9">Porque devo acreditar, que és a pessoa indicada para ser parceiro/sócio de uma Startup?</label></span>
<input id="q9" name="q9" type="text" />
</li>
<li> <span><label for="q10">Tens algum trabalho realizado? (Mesmo privado ou escolar) Se sim, coloca os links ou envia os projectos para o dropbox (em baixo!).</label></span>
<input id="q10" name="q10" type="text" />
</li>
<li> <span><label for="q11">Tens algum projecto em desenvolvimento ou que desejarias criar? Dá uma breve descrição, da tua ideia</label></span>
<input id="q11" name="q11" type="text" />
</li>
<li> <span><label for="q12">Quais são os teus objectivos, em relação ao projecto? (Pessoais e profissionais)</label></span>
<input id="q12" name="q12" type="text" />
</li>
<li> <span><label for="q13">Digita o teu email (Ex.: fake.email@gmail.com)</label></span>
<input id="q13" name="email" type="text" />
</li>
</ol>
<!-- /questions -->
<button class="submit" type="submit" name="submit">Submeter</button>
<div class="controls">
<button class="next"></button>
<div class="progress"></div> <span class="number">
<span class="number-current"></span>
<span class="number-total"></span>
</span> <span class="error-message"></span>
</div>
<!-- / controls -->
</div>
PHP
ini_set('display_errors', 1);
error_reporting(~0);
$one = $_POST['q1']; // Requesting user's first name
$two = $_POST['q2']; // first question
$three = $_POST['q3']; // required
$four = $_POST['q4']; // required
$five = $_POST['q5']; // required
$six = $_POST['q6']; // required
$seven = $_POST['q7']; // required
$eight = $_POST['q8']; // required
$nine = $_POST['q9']; // required
$ten = $_POST['q10']; // required
$eleven = $_POST['q11']; // required
$twelve = $_POST['q12']; // last question
var_dump($_POST);
if(isset($_POST['submit'])){
$to = "uniqezor@gmail.com"; // this is your Email address
$mail_from = $_POST['email']; // this is the sender's Email address
if(trim($_POST['email']) == '') {
$hasError = true;
} else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) {
$hasError = true;
} else {
$email = trim($_POST['email']);
}
$subject = "Submissão de formulário de interessado!";
$message = "Eu sou " . $one . " e respondi ao formulário o seguinte:" . "\n\n" .
"<strong>Pergunta 1: Qual é a tua área? </strong>" . $two . "<br/>
<strong>Pergunta 2: Qual é a tua área? </strong>" . $three . "<br/>
<strong>Pergunta 3: Qual é a tua área? </strong>" . $four . "<br/>
<strong>Pergunta 4: Qual é a tua área? </strong>" . $five . "<br/>
<strong>Pergunta 5: Qual é a tua área? </strong>" . $six . "<br/>
<strong>Pergunta 6: Qual é a tua área? </strong>" . $seven . "<br/>
<strong>Pergunta 7: Qual é a tua área? </strong>" . $eight . "<br/>
<strong>Pergunta 8: Qual é a tua área? </strong>" . $nine . "<br/>
<strong>Pergunta 9: Qual é a tua área? </strong>" . $ten . "<br/>
<strong>Pergunta 10: Qual é a tua área? </strong>" . $eleven . "<br/>
<strong>Pergunta 11: Qual é a tua área? </strong>" . $twelve . "<br/>";
$headers = "Enviado por: $q1 <$mail_from>";
mail($to,$subject,$message,$headers);
}
答案 0 :(得分:1)
您没有发布表单,默认方法是GET
。
变化:
<form id="theForm" class="simform animated fadeIn" autocomplete="off" action="send.php" name="form">
为:
<form method="post" id="theForm" class="simform animated fadeIn" autocomplete="off" action="send.php" name="form">