Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Include required functions.
- require_once ("php/_functions/send_mail.php");
- // Prepare necessary variables for later use.
- $Page = "_contact_form";
- // Check if page was submitted, and within time.
- if (Check_Submit ($Template->BUTTON_SUBMIT, 600)) {
- // Was, prepare necessary variables for later use.
- $Message = array ();
- // Validate input variables.
- $Name = Validate ('name', 'name', 'NAME', 'FORM_NAME', $Message, 60, "æøåÆØÅöÖäÄéá");
- $Email = Validate ('email', 'email', 'EMAIL', 'FORM_EMAIL', $Message);
- $Comments = Validate ('string', 'message', 'MESSAGE', 'FORM_MESSAGE', $Message, "+", "\r\n.?!:;,/'\"%@æøåÆØÅöÖäÄ_£€$");
- // Check to see if everything validated correctly.
- if (!empty ($Message)) {
- // Didn't, prepare the error message for display, and stop processing.
- $Message = "<ul>\n\t<li>".implode ("</li>\n\t<li>", $Message)."</li>\n</ul>\n";
- $Template->_MESSAGE = '<p id="form_error" class="message error">'.sprintf ($Template->ERROR_FORM, $Message)."</p>\n";
- return;
- }
- // Send mail to site owner.
- Send_Mail ($Name, $Email, $Template->MAIL_CONTACT_SUBJECT, $Comments);
- // Succeeded, send to "OK" page and prevent F5-resend.
- header ("Location: {$Template->_PHP_SELF}send=ok");
- die ();
- }
- // Check if form was submitted at all.
- if (Check_Submit ($Template->BUTTON_SUBMIT)) {
- // Wasn't submitted within time limit, show warning and populate fields with submitted data.
- $Template->_FORM_FIELD_NAME = htmlspecialchars ($_POST['name']);
- $Template->_FORM_FIELD_EMAIL = htmlspecialchars ($_POST['email']);
- $Template->_FORM_FIELD_MESSAGE = htmlspecialchars ($_POST['message']);
- $Template->_MESSAGE = '<p id="form_error" class="message error">'.$Template->ERROR_TIME_EXPIRED."</p>\n";
- unset ($_GET['send']);
- }
- // Check if submission was completed successfully.
- if ($_GET['send'] == "ok") {
- // Mail was sent successfully, and it's time to display the "OK" message.
- $Template->_MESSAGE = '<p id="form_error" class="message green">'.$Template->MAIL_SUBMITTED."</p>\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment