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

  • Home
  • SEARCH
  • 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 7030921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:44:07+00:00 2026-05-28T00:44:07+00:00

Hi there I have edited some code I have found on-line and everything works

  • 0

Hi there I have edited some code I have found on-line and everything works besides the validation. It always seems to send an email even when all fields are blank on the contact form that I’ve created. It is definitely an easy fix but I’m new to this so any help means a great deal to me!!

Thanks.

Heres the code Im using for the php script:

/////////////////////////////////////////////////////

<?php
// Contact subject
$subject ="$Email Enquiry"; 
// Details
$message=("$cComment") ; 

// Mail of sender
$mail_from="$cEmail"; 
// From 
$header="from: $cName <$mail_from>"; 

// Enter your email address
$to ='info@blahblahblah.net'; 

$send_contact=mail($to,$subject,$message, $header);

// Check, if message sent to your email 
// display message "We've recived your information"
if($mail_from != "Email"){
header('Location:thanksemail.php');
}
else {
header('Location:emailfail.php');
}
?>
  • 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-05-28T00:44:08+00:00Added an answer on May 28, 2026 at 12:44 am

    You haven’t got any checking code. The code that sends the mail is $send_contact=mail($to,$subject,$message, $header);
    The checking must be before this code

    Try this

    if($subject!="" && $cComment!="" && $cEmail!="" && $cName!="" && $mail_from!=""){
    $send_contact=mail($to,$subject,$message, $header);
    
    if($mail_from != "Email"){
    header('Location:thanksemail.php');
    }
    else {
    header('Location:emailfail.php');
    }
    
    
    }else{
    header('Location:emailfail.php');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There have been some questions about whether or not JavaScript is an object-oriented language.
I have some code for validating date below: function validateForm() { var errFound =
I have an idea for a hobby project which performs some code analysis and
I have edited this from my real code, so that it is a little
This is the edited code: I have a two dimensional stack, like #define push(s,ele)
I have done some research prior to and have found some great articles but
I have some code that reads a file into an array of lines, and
I have Button.When the user click the button, there are some condition, that condition
I have an app that uses EF POCO for accessing data. Everything works great,
For some reason, I have to move a lot of C# code from Visual

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.