View Single Post
Old 05-13-2015, 04:47 AM   #17
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,216
Default

ok im rambling again. on your form you have send.php as the action so are you changing the php in send.php?
in any case here it is again but as one page, so it calls itself once submitted. this definitely works this time it sends an html mail. give it a whirl

Code:
<?php
  $machine = $_POST['myrealname'];
    if ($machine != "")
    { echo 'naff off spammer';
        exit(); //if a spambot filled out the "machine"
                //field, we don't proceed
    }
        else{
 
 
    if (isset($_POST['Submit']) && $_POST['name'] != "") {
		
		$th_url= "thankyou.html";   // modify to page redirect after mail succsessfully sent
 
        if ($_POST['name'] != "") {
            $_POST['name'] = filter_var($_POST['name'], FILTER_SANITIZE_STRING);
            if ($_POST['name'] == "") {
                $errors .= 'Please enter a valid name.<br/><br/>';
            }
        } else {
            $errors .= 'Please enter your name.<br/>';
        }
 
        if ($_POST['email'] != "") {
            $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
            if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
                $errors .= "$email is <strong>NOT</strong> a valid email address.<br/><br/>";
            }
        } else {
            $errors .= 'Please enter your email address.<br/>';
        }
		
	/*	Validating  web address in form field  **********************************************     */
		
		   if ($_POST['website'] != "") {
            $website = filter_var($_POST['website'], FILTER_SANITIZE_URL);
            if (!filter_var($website, FILTER_VALIDATE_URL)) {
                $errors .= "$website is <strong>NOT</strong> a valid URL.<br/><br/>";
            }
        } else {
            $errors .= 'Please enter your home page.<br/>';
        }
	/*	 end Validating  web address in form field  **********************************************     */	
 
      
        if ($_POST['Message'] != "") {
            $_POST['Message'] = filter_var($_POST['Message'], FILTER_SANITIZE_STRING);
            if ($_POST['Message'] == "") {
                $errors .= 'Please enter a message to send.<br/>';
            }
        } else {
            $errors .= 'Please enter a message to send.<br/>';
        }
 
        if (!$errors) {
            $to = 'myemail@gmail.com';
            $subject = 'New Mail from  ' . $_POST['email'];
			
			  $headers = "From: " . strip_tags($to) . "\r\n";
  $headers .= "Reply-To: ". strip_tags($to) . "\r\n";
   $headers .= "MIME-Version: 1.0\r\n";
  $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
			
		$message = '<html><body>';
 
$message .= '<table width="100%";  style="border:1px solid #3A5896;" cellpadding="10">';
$message .='<tr><td>'. 'From: ' . $_POST['name'].  '</td></tr>'; 
$message .= '<tr><td >'.'Email from: ' . $_POST['email'] . ' </td></tr>'; 
 $message .= '<tr><td >'."Message:\n" . $_POST['Message'] . ' </td></tr>'; 
$message .= "</table>";
 
$message .= "</body></html>";	
			
            mail($to, $subject, $message, $headers );
 
          
    header("Location: $th_url");
			
        } else {
            echo '<div style="color: red">' . $errors . '<br/></div>';
        }
    }
		}
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Contact</title>
<style>
#form{
 position:relative;
 width: 500px;
 margin:0 auto;
}
 label {
     float:left;
    clear:left;
}
 input[type="text"], [type="url"], [type="email"]{
	 float:left;
    color: #555 ;
    width: 70%;
    border: 1px solid #e5e5e5;
    background: #fbfbfb;
    height: 25px;
}
 .textarea{
	  float:left;
    height:100px;
      width: 70%;
}
.robotic { display: none; }
</style>
</head>
<body>
<div id="form">
<form action="" method="post">     
   <fieldset>
            <label for="name">Name:</label>
            <input id="name" name="name" type="text" required 
            placeholder=" Your name"   >
          </fieldset>
         <fieldset>       
            <label >Email:</label>
            <input type="email" id="email" name="email" placeholder="me@mymail.com" required >
                    </fieldset>
         <fieldset>  
   
            <label>Website:</label>
            <input type="url" id="website" name="website"  placeholder=" http://mysite.com" required >
                    </fieldset>
         <fieldset>  
            <label>Message</label>
            <textarea class="textarea" name="Message" id="Message"  ></textarea>     
           </fieldset>
         <fieldset>  
         <input class="robotic" type="text" name="myrealname" id="myrealname" >
            <input type="submit" name="Submit" value="Submit">    <input name="reset" type="reset">
           </fieldset>
    
</form> 
 </div>     
</body>
</html>
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote