email form (cannot find the problem)


Posted on 16th Feb 2014 07:03 pm by admin

Hello there. I've been having trouble with an email form. Can't find the problem really. I've tested so many times, tried different ifs to see where the problem comes from. It turned out its alway the last ELSE. The one that doesnt have explanation to me. Here we go: Code: if(isset($_GET['send'])) {

$email=filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
//$email = htmlentities($email,ENT_QUOTES);
Did you know?Explore Trending and Topic pages for more stories like this.
$body=stripslashes($_POST['body']);
$date = date("F j, Y, g:i a");
$valid = preg_match('/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*@([a-z0-9])*(.([a-z0-9])([-a-z0-9_-])([a-z0-9])+)*$/i','09_az..AZ@host.dOMain.cOM');
$spam=preg_match('/(r|n)(to:|from:|cc:|bcc:)/',$body);
$ip = substr($_SERVER['REMOTE_ADDR'], 0, strrpos($_SERVER['REMOTE_ADDR'], "."));

if ($email && $body && $valid && !$spam) {
if ( mail( $to, "Feedback Form Results", $body, "From: $email" )) {

echo '<p>'.$thanks.'</p>';
$email='';
$body='';
}
else {
echo '<p>'.$error.'</p>';
$email='';
$body='';
}
}
else if ($spam) {
echo '<p>'.$spamattack.'</p>';
$email='';
$body='';
}
else {
echo'<p><strong>'.$fillin.'</strong></p>';
$email='';
$body='';
}

}
No comments posted yet

Your Answer:

Login to answer
298 Like 46 Dislike
Previous forums Next forums
Other forums

Run function every 5 mins ??
I have a function PostMessage()

How can I run it every 5 mins ??

parsing error
can anyone explain this syntax error:

Parse error: syntax error, unexpected T_IF

The e

FILTER_CALLBACK -- Files?
Hi All,

I'm using the php filter functions to validate my form data. For custom filters, I'm

Using loop to count number of entries
I'm writing a program that must ask user to type in numbers. After each entry, the program has to re

Redirect not working after making a POST/GET
Hi Everyone,

I am a novice in PHP. Here I have 2 pages, one page with a textbox and button an

Format String help
I have a textbox where a person enters an application number. the application number is 10 characte

MySQL query problem
When I try to run the following piece of code, I get this error:
QuoteWarning: mysql_query(): sup

Else statement screws up all css
Does anyone know what goes wrong in the process with this php code?
This code seems to be causing

Which PHP-Editor do you think is the best?
Hi everyone,
Myself Brian Anderson. For the last 2 years i have been working a

Putting double spaces instead of single spaces
Im looking at trying to replace all single spacing between fields with double spacing

At pres

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash