Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8649805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:39:00+00:00 2026-06-12T13:39:00+00:00

I hope I’m missing something pretty basic here but: An empty form is getting

  • 0

I hope I’m missing something pretty basic here but: An empty form is getting submitted randomly, sometimes 3-8 times a day, then none for a few days and so on.

The empty submits always email with the subject as “[Website Contact Form].” Even though there is no validation in my php, in the html code the subject is chosen from a drop-down menu with the default as “General Enquiry.” Notice in the php code below, there is no way for a human to submit an empty form with the above subject line, that is, it would always be “[Website Contact Form]General Enquiry” if I press submit without entering anything.

I have contact.html call this contact.php file:

<?
   $email = 'info@mail.com';
   $mailadd = $_POST['email'];
   $headers = 'From: ' . $_POST['email'] . "\r\n";
   $name = $_POST['name'];
   $subject = '[Website Contact Form] ' . $_POST['subject'];
   $message = 'Message sent from: ' . $name . '. Email: ' . $mailadd . '. Organization: ' . $_POST['company'] . '. Phone: ' . $_POST['phone'] . '. ';
   $message .= 'Message: ';
   $message .= $_POST['message'];

   if (mail($email,$subject,$message, $headers)) {
    echo "<p>Thank You! We'll get back to you shortly.</p>";
   }
   else {
    echo "<p>Error...</p>";
   }
?>

I use this code for many websites, but have never encountered this issue. Is there something so obviously wrong with this code that I’m missing? Any help would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:39:01+00:00Added an answer on June 12, 2026 at 1:39 pm

    I suspect that you may not be checking that these variables are set before you send the email. Someone requesting contact.php directly (without any form data) may produce the results you have described. If this is the case, the following code should work like a charm:

    <?php
        if (isset($_POST['submit']) {
            // form code
        }
        else {
            // The form was not submitted, do nothing
        }
    ?>
    

    Even if that’s not that case, such a simple check is always good practice.

    Furthermore, you should always validate any user input just as a good habit. You don’t want your server flooding your inbox with emails. I suggest using regexs to validate the input provided and possibly use a captcha service (such as ReCaptcha).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hope everybody is cool.I've been trying to do something with spring-hibernate but it's still
Hope some1 here knows why I am missing these properties.... If I take a
hope you can help me (tried lots of things here, but nothing worked) i
Hope you can help me with this its probably really simple but I'm pretty
hope someone can answer this. Here is some sample code. namespace std { #ifdef
hope all is swell! I was hoping I had cracked this problem but it
Hope someone will give me a hand with this problem I have. So here
Hope you're having a good Friday and stuff... okay, so here's my question: All
Hope someone can help, I'm not a programmer, but have been interested in exploring
hope someone can help me out here. I have the following structure in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.