PHP Mail Form Help

I made a PHP Email form on one of the pages of my website, but there’s a problem. Even though it displays “ALL FIELDS REQUIRED” when a field is missing, it still sends the message. I can’t figure out what I’m doing wrong.

I would post the link to the page and let you just view the source code, but for some reason it isn’t showing in the source code =( Could someone give me their email address and let me send them the notepad version? I really need help with this.

How do you check whether the field is empty?

Usually I check using these two functions isset() and empty()

if (!isset($_POST["###"]) or empty($_POST["###"])){
// some fields are missing
// continue

If you do not use empty(), you may have a situation that a variable exists but with empty value.

Save $97 (MAX Discount) with code: [color=#CC0000]97YES[/color] Sign Up NOW or More Codes Here

<?php // process the form if (array_key_exists('send' , $_POST)) { $to = '' ; $subject = 'Rebirth Affiliation Request' ; // list required and expected fields $expected = array('title', 'url', 'button', 'email'); // set the required fields $required = array('title', 'url', 'button', 'email'); // create an empty array for missing fields $missing = array(); // assume there is nothing to suspect $suspect = false; // create a pattern to locate suspect phrases $pattern = '/Content-Type:|Bcc:|Cc:/i'; // process post variables $title = $_POST['title']; $url = $_POST['url']; $button = $_POST['button']; $email = $_POST['email']; // time to build the message! $message = "Title: $title\n\n"; $message .= "URL: $url\n\n"; $message .= "Button: $button\n\n"; $message .= "Email: $email\n\n"; // time to send the message $mailSent = mail($to, $subject, $message); } if ($mailSent) { // missing is no longer needed unset($missing); } ?>

That’s all of the code I use before the opening HTML tag.

try to change

if (array_key_exists(‘send’ , $_POST)) {


if (array_key_exists(‘send’ , $_POST) and !empty($_POST[“send”])) {

key ‘send’ may exist but with an empty value

Save $97 (MAX Discount) with code: [color=#CC0000]97YES[/color] Sign Up NOW or More Codes Here

Added that, and it still sends the mail when the fields are blank.


I think ‘send’ is a button but not one of the fields. If it is a button, it always returns a value which is set in the button tag.

For your case, I think you should check title, url, button, email. Try to replace ‘send’ with those field names.

Save $97 (MAX Discount) with code: [color=#CC0000]97YES[/color] Sign Up NOW or More Codes Here