Created
January 3, 2014 15:14
-
-
Save juniorb2ss/8239460 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Utilizando a função isset, perguntamos ao PHP se esta variavel realmente existe. | |
// http://br2.php.net/isset | |
if (isset($_POST['submit']) isset($_POST['name']) isset($_POST['email']) isset($_POST['message']) ) { | |
// É preciso apenas pegar os valores do POST após ter requisição. | |
$name = $_POST['name']; | |
$email = $_POST['email']; | |
$message = $_POST['message']; | |
$from = 'From: TangledDemo'; | |
$to = 'marcelohcortez@gmail.com'; | |
$subject = 'Hello'; | |
$human = $_POST['human']; | |
$body = "From: $name\n E-Mail: $email\n Message:\n $message"; | |
// Agora iremos utilizar a função empty(), função que é responsável por perguntar se tal variavel esta limpa. | |
// http://www.php.net/manual/pt_BR/function.empty.php | |
// | |
// OBS: Vale ressaltar que empty é diferente de isset, empty se usa quando uma váriavel já é existente na execução do código, isset pergunta se a váriavel é existente. | |
// | |
if (!empty($name) && empty($email)) | |
{ | |
if ($human == '4') | |
{ | |
if (mail ($to, $subject, $body, $from)) | |
{ | |
echo '<p>Your message has been sent.</p>'; | |
} | |
else | |
{ | |
echo '<p>Something went wrong, go back and try again.</p>'; | |
} | |
} | |
elseif ($_POST['submit'] && $human != '4') | |
{ | |
echo '<p>You answered the anti-spam question incorrectly.</p>'; | |
} | |
} | |
else | |
{ | |
echo '<p>You need to fill in all required fields.</p>'; | |
} | |
} | |
?> | |
<?php include('header.php'); ?> | |
<div class="geral"> | |
<div class="contact"> | |
<div class="panelcollapsed"> | |
<h2> JUST TALK | |
<p> Have any sugestions, corrections, praising, critics on Visual Dose? </p> | |
<p> Send us your opinion. </p> </h2> | |
<div class="panelcontent"> | |
<form method="post" action="contact.php"> | |
<label>Name</label> | |
<input name="name" placeholder="Type Here"> | |
<label>Email</label> | |
<input name="email" type="email" placeholder="Type Here"> | |
<label>Message</label> | |
<textarea name="message" placeholder="Type Here"></textarea> | |
<label>*What is 2+2? (Anti-spam)</label> | |
<input name="human" placeholder="Type Here"> | |
<input id="submit" name="submit" type="submit" value="Submit"> | |
</form> | |
</div> | |
</div> | |
</div> | |
</div> | |
<?php include('footer.php'); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment