Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('display_errors',1);
- error_reporting(E_ALL|E_STRICT);
- // -----------------------------------------
- // The Web Help .com
- // -----------------------------------------
- // remember to replace you@email.com with your own email address lower in this code.
- // load the variables form address bar
- $subject = $_POST["subject"];
- $message = $_POST["message"];
- $from = $_POST["from"];
- $verif_box = $_POST["verif_box"];
- // remove the backslashes that normally appears when entering " or '
- $message = stripslashes($message);
- $subject = stripslashes($subject);
- $from = stripslashes($from);
- // check to see if verificaton code was correct
- if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
- // if verification code was correct send the message and show this page
- mail("abhijit.infogence@gmail.com", 'TheWebHelp.com Form: '.$subject, $_SERVER['REMOTE_ADDR']."nn".$message, "From: $from");
- // delete the cookie so it cannot sent again by refreshing this page
- setcookie('tntcon','');
- } else if(isset($message) and $message!=""){
- // if verification code was incorrect then return to contact page and show error
- header("Location:".$_SERVER['HTTP_REFERER']."?subject=$subject&from=$from&message=$message&wrong_code=true");
- exit;
- } else {
- echo "no variables received, this page cannot be accessed directly";
- exit;
- }
- ?>
- <form method="POST" action="yourfile.php">
- etc.
- </form>
- print_r($_POST);
- print_r($_COOKIE);
- foreach(array('subject', 'message', 'from', 'verif_box') as $val)
- {
- if (isset($_POST[$val]))
- {
- $$val = trim($_POST[$val]);
- continue;
- }
- // some sort of error checking, like telling the end user that
- // not all fields were correctly given
- }
- $subject = (isset($_POST["subject"]) ? $_POST["subject"] : '');
- $message = (isset($_POST["message"]) ? $_POST["message"] : '');
- $from = (isset($_POST["from"]) ? $_POST["from"] : '');
- $verif_box = (isset($_POST["verif_box"]) ? $_POST["verif_box"] : '');
- function checkPost($fieldname)
- {
- return (isset($_POST[$fieldname]) ? $_POST[$fieldname] : '');
- }
- $subject = checkPost("subject");
- if (!isset($_POST["xxx"]) || trim($_POST["xxx"]) == '')
- {
- // throw exception, display error...
- }
- //checking if array elements are set and changing variables values if so
- $subject = isset($_POST["subject"])?$_POST["subject"]:null;
- $message = isset($_POST["message"])?$_POST["message"]:null;
- $from = isset($_POST["from"])?$_POST["from"]:null;
- $verif_box = isset($_POST["verif_box"])?$_POST["verif_box"]:null;
- // check to see if verificaton code was correct and if cookie value on 'tntcon' is set
- if(isset($_COOKIE['tntcon']) && md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement