logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 05-12-2015, 12:44 PM   #11
d a v e
 
Join Date: Feb 2006
Location: finland
Posts: 1,684
Default

hmm - put in the new html and php and used my email address http://gekkoweb.com/hl2015/form.html but now when i fill it in and press submit it simply refreshes the form or empties it. no email arrives, it isn't redirected to the thank you page. no error message
d a v e is offline   Reply With Quote
Old 05-12-2015, 02:03 PM   #12
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

Thats odd.ill check in the morning when i get in the office. I did test it live this time so im not sure at the moment
__________________
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
Old 05-12-2015, 02:11 PM   #13
d a v e
 
Join Date: Feb 2006
Location: finland
Posts: 1,684
Default

probably me then i'll try it again when i get time and let you know
d a v e is offline   Reply With Quote
Old 05-12-2015, 02:15 PM   #14
d a v e
 
Join Date: Feb 2006
Location: finland
Posts: 1,684
Default

tried again - copy and pasted you code and only modifed the email (to mine) same thing. form just resets
d a v e is offline   Reply With Quote
Old 05-13-2015, 01:15 AM   #15
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

sorry Dave the error is at the form i suspect, when i tested this i used as a one page, ie the php block above the html code. i then just split it and posted separately.
I retested it today and it is working. BTW to debug change in the form
Code:
<input class="robotic" type="text" name="myrealname" id="myrealname">

to <input class="robotic" type="text" name="myrealname" id="myrealname" value="anything">
that should kill the script as if a spambot filled the form
__________________
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
Old 05-13-2015, 04:32 AM   #16
d a v e
 
Join Date: Feb 2006
Location: finland
Posts: 1,684
Default

not sure i understand - changed that line and it still doesn't work - did you mean something else?
d a v e is offline   Reply With Quote
Old 05-13-2015, 04:47 AM   #17
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
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
Old 05-13-2015, 04:51 AM   #18
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

acctually i just tested your fornm and it retured the error please enter home page which is not on the form.

the validaytion for that is

Code:
/*	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/>';
        }
its not my favorite as it must include http:// and i think that can be a problem. you can remove or comment that out if you choose
__________________
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
Old 05-13-2015, 04:57 AM   #19
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

ok i put it online and sent using your email address , have a look in your inbox. ill delete it soon
__________________
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
Old 05-13-2015, 06:10 AM   #20
d a v e
 
Join Date: Feb 2006
Location: finland
Posts: 1,684
Default

nothing in my inbox or spam folder for gekkoweb@gmail.com
d a v e is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:46 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com