14, February 2012

How do I block an email in my forms? - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: How do I block an email in my forms?
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: How do I block an email in my forms?  (Read 1525 times)
Metal slug addict
*
Posts: 18
140 credits
Members referred : 0


« on: Aug 05, 2008, 11:39:05 pm »

I have a simple PHP contact form. But I have email spammer that keeps filling out my form. How do I add a block so that email cannot even be sent from the spammer?
Here my code:
Code:
<?php


// get posted data into local variables
$EmailFrom Trim(stripslashes($_POST['EmailFrom'])); 
$EmailTo "smurfmebaby@yahoo.com";
$Subject "Our Form";
$FirstName Trim(stripslashes($_POST['FirstName'])); 
$LastName Trim(stripslashes($_POST['LastName'])); 
$Phone Trim(stripslashes($_POST['Phone'])); 
$Reason Trim(stripslashes($_POST['Reason'])); 
$IP=$_SERVER['REMOTE_ADDR'];

// validation
$validationOK=true;
if (
Trim($EmailFrom)==""$validationOK=false;
if (!
$validationOK) {
  print 
"<meta http-equiv=\"refresh\" content=\"0;URL=oops.html\">";
  exit;
}

// prepare email body text
$Body "";
$Body .= "FirstName: ";
$Body .= $FirstName;
$Body .= "\n";
$Body .= "LastName: ";
$Body .= $LastName;
$Body .= "\n";
$Body .= "Phone: ";
$Body .= $Phone;
$Body .= "\n";
$Body .= "Reason: ";
$Body .= $Reason;
$Body .= "\n";
$Body .= $IP;
$Body .= "\n";

// send email 
$success mail($EmailTo$Subject$Body"From: <$EmailFrom>");

// redirect to success page 
if ($success){
  print 
"<meta http-equiv=\"refresh\" content=\"0;URL=thanks.html\">";
}
else{
  print 
"<meta http-equiv=\"refresh\" content=\"0;URL=oops.html\">";
}
?>

Do I just add something in the Valdiation?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Aug 06, 2008, 07:46:57 am »



Last blog : A new Wordpress theme for our blog
Metal slug addict
*
Posts: 18
140 credits
Members referred : 0


« Reply #2 on: Aug 06, 2008, 03:35:31 pm »

Thanks, that was good info to read. But I am looking for more of a block that won't allow a certain email to be used in the form. Like an @gmail.com. So if they add name@gmail.com. It will give them the error page. Is that possible? I guess I am tryiing to make @gmail.com a banned or bad word?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: Aug 06, 2008, 04:24:41 pm »

Thanks, that was good info to read. But I am looking for more of a block that won't allow a certain email to be used in the form. Like an @gmail.com. So if they add name@gmail.com. It will give them the error page. Is that possible? I guess I am tryiing to make @gmail.com a banned or bad word?

what you're trying is not the solution, after you block his address he will use the next one, you need to stop BOTs. You need something else like a captcha validation


Last blog : A new Wordpress theme for our blog
Metal slug addict
*
Posts: 18
140 credits
Members referred : 0


« Reply #4 on: Aug 06, 2008, 04:49:39 pm »

Oh I see now. Stop it all and they can't change the email and do it agian. Thanks so much for your help.
Radical Sales Monster
Computer Avant Garde
***
Posts: 206
430 credits
Members referred : 0


« Reply #5 on: Aug 09, 2008, 08:42:15 pm »

What about using e-mail confimration. If you do this it will not matter if he signs up. He will not confirm the e-mail and you have nothing to worry about. I do this and so do my clients. Capthca on an e-mail form is a pain and can sometimes cost you less web savvy readers.


Last blog : Sign up for the newsletter and get 40 hours of mentorship
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=7889
Tags : PHP Contact Form Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: How do I block an email in my forms?
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Feb 14, 2012, 09:47:05 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.