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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:52:09+00:00 2026-06-14T12:52:09+00:00

I want to display messages at top ids MessageError and MessageOK according to POST

  • 0

I want to display messages at top ids “MessageError” and “MessageOK” according to POST results. Example:

<p id="MessageError"></p>
<p id="MessageOK"></p>

<form name="Form" method="post" action="<?php $_SERVER[ 'PHP_SELF' ]; ?>" enctype="multipart/form-data" accept-charset="UTF-8" id="Form">
  <input type="text" name="test" value="" /> <input type="submit" name="Submit" value="" />
</form>

<?php
if ( isset ( $POST[ 'Submit' ] ) ) {
  if ( $_POST[ 'test' ] ) {
    // Echo message at "MessageOK
  }
  else {
    // "Echo message at "MessageError"
  }

}
?>

Any help will be appreciated.

Thank you.

  • 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-14T12:52:11+00:00Added an answer on June 14, 2026 at 12:52 pm

    Move the code above your form to print the error message above your form. Also your paragraph tags can be created on the fly, to avoid waste:

    <?php
        if(isset($_POST['submit'])){
            if($_POST['test'])echo("<p id='MessageOk'>There was an Error</p>");
            else echo("<p id='MessageError'>There was no error</p>");
        }
    ?>
    

    If you are dead set on adding content to pre-created divs using PHP, can I suggest creating an input using PHP eg:

     <?php
            $test = $_POST['test'];
            echo("<input type='hidden' id='test' value='$test' />");
     ?>
    

    And then using JavaScript to append data:

    if(document.getElementById('test').value){
        document.getElementById('MessageOk').innerHTML = 'No Error';
    }
    else{
        document.getElementById('MessageError').innerHTML = 'Error ??';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to display a Save Successful message at the top of my form
I want to display my jQuery validation messages in a tooltip. In order to
Simply, I want to display the number of unread messages in a label inside
I have a form in a Windows form application that I want to display
I want to display error messages in my view. What is the best way
I want to display 5 user feedback messages in a span with the id
I want to display message box contain label and textbox and ok button and
I want to display error message or alert message after checking the condition. here
I want to display the message Hi how are you? for 1 minute using
I have a page that displays messages and I want it to work just

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.