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 8699347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:55:33+00:00 2026-06-13T01:55:33+00:00

I am a PHP newb so please bear with me for this rather simplistic

  • 0

I am a PHP newb so please bear with me for this rather simplistic question.

I have a PHP form setup like so >>

<?php
    if($_POST){
        $name = $_POST['name'];
        $email = $_POST['email'];
        $message = $_POST['message'];
        $comments = $_POST['comments'];

        if($comments)
            $error = "There was an error, please give us a call at ### ###-####.";
        else{
            if($name=="Name" || $email=="Email" || $message=="Message"){
                $error = "All fields are required, please fill them out and try again.";
            }else
            $header = "From: $name <$email>";
                $message = "Name: $name\n\nEmail: $email\n\nMessage: $message";
                if(mail("email@domain.com", 'Form Submission', $message, $header))
                    $success = "Thanks for sending us your message, we'll get back to you shortly.";
                else
                    $error = "There was an error, please give us a call at ### ###-####.";
        }
        if($error)
            echo '<div class="msg error">'.$error.'</div>';
        elseif($success)
            echo '<div class="msg success">'.$success.'</div>';
    }
?>

The basic idea is that the form has descriptive text pre-filled in each field but when you click on them they are cleared via Javascript. I want to prevent people from pressing send on the form without filling it out, hence the “if($name==”Name” || $email==”Email” || $message==”Message”){” bit. However while that message is working the form is still submitting. Why is this. Also please note that the “comments” field is in fact a honeypot. Thanks!

  • 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-13T01:55:34+00:00Added an answer on June 13, 2026 at 1:55 am

    Because php is server-side. You need to look into javascript validation for what you want. To validate with php you HAVE to submit the form.

    One tutorial but I recommend Jquery validation

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

Sidebar

Related Questions

I'm a PHP newb. Sorry if this is an FAQ... Let's say I have
I am a PHP newb. I have the following code for a web form.
I am a php newb and I don't have a clear answer for this.
I'm new to PHP and web scripting in general so this a newb question.
sorry for this newb question, i just started programming with php I'm following Yahoo
Quick PHP Question. I am kinda newb to PHP so bear with me. Why
Hi please have a look on bellow code. <?php class A { public $name;
PHP code: echo date(c); //out put like this 2012-06-19T20:37:44+05:30 echo date(d M, Y); //out
PHP: I have made up a function that returns an array. I would like
I'm a total newb to security, so I have a really simple question: Is

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.