Created
November 22, 2012 15:57
-
-
Save eakmotion/4131841 to your computer and use it in GitHub Desktop.
PHP: Form send single page
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 | |
if($_SERVER["REQUEST_METHOD"] == "POST"){ // check $_POST value before process | |
$name = $_POST["name"]; | |
$email = $_POST["email"]; | |
$message = $_POST["message"]; | |
$email_body = ""; | |
$email_body = $email_body . "Name : " . $name . "\n" ; | |
$email_body = $email_body . "Email : " . $email . "\n"; | |
$email_body = $email_body . "Message : " . $message ; | |
header("Location: contact.php?status=thank"); // redirect Thank you in the same page , set $_GET value , header -> command used in a PHP file to redirect | |
exit; | |
} | |
$section = "contact"; | |
$pageTitle = "Contact Mike"; | |
include('inc/header.php'); ?> | |
<div class="section page"> | |
<div class="wrapper"> | |
<h1>Contact</h1> | |
<?php if (isset($_GET["status"]) AND $_GET["status"] == "thank" ) { // isset -> check $_GET exist and check $_GET equal value ?> | |
<p>Thank You for the email</p> | |
<?php } else { ?> | |
<p>I'd love to here from you</p> | |
<!-- form[method="post"]>table>tr(th(label[for=name]{Name})+td(input[type="text" name="name" id="name"]))*3 --> | |
<form action="contact.php" method="post"> | |
<table> | |
<tr> | |
<th><label for="name">Name</label></th> | |
<td><input type="text" name="name" id="name"></td> | |
</tr><tr> | |
<th><label for="email">Email</label></th> | |
<td><input type="text" name="email" id="email"></td> | |
</tr><tr> | |
<th><label for="message">Message</label></th> | |
<td><textarea name="message" id="message"></textarea></td> | |
</tr> | |
</table> | |
<input type="submit" value="Send"> | |
</form> | |
<?php } ?> | |
</div> | |
</div> | |
<? include('inc/footer.php'); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment