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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:29:06+00:00 2026-05-25T03:29:06+00:00

When I test to see if the textarea in my form is empty to

  • 0

When I test to see if the textarea in my form is empty to do a redirect so it doesn’t submit it in php, it doesn’t work.

The textarea is named $_POST['message'], I know the variable exists because if I do this statement;

if (isset($_POST['message'])) {
    header('Location:/');
    exit();
}

Then it always redirects back to the index page so the variable must exist, although if I do this;

if (empty($_POST['message'])) {
    header('Location:/');
    exit();
}

It does not work, also tried with all three combos of =/==/===

if ($_POST['message'] === '') {
    header('Location:/');
    exit();
}

And also…

if (empty(trim($_POST['message']))) {
    header('Location:/');
    exit();
}

Any ideas why this is happening? And how I can prevent it, I really need to stop it as I do not want empty values in my mysql table.

I did some research and it seems some other people have had this problem, but I have seen no answer as of yet.

  • 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-25T03:29:07+00:00Added an answer on May 25, 2026 at 3:29 am

    You probably have some whitespaces in the string, which isn’t stripped by trim().

    Do a strlen() on it to see what’s up, and then log it byte by byte (http://stackoverflow.com/questions/591446/how-do-i-get-the-byte-values-of-a-string-in-php).

    One thing you could think about is to make sure your textarea doesn’t have any content in the markup (spaces, linkebreaks, whatever), like this:

    <textarea></textarea>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<form> <textarea name=test value=no> hi </textarea> <input type=submit /> </form> hi or no,and reason?
How could I test to see if SQL injection doesn't work in a textbox
I know how to test an object to see if it is of a
I want to test to see if a variable has been assigned a variable
I have form: <form method='post' action='script.php'> <textarea id='main' name='text'></textarea> <input type='hidden' name='id' value='1'> <input
I usually never see test for new in C++ and I was wondering why.
Is there a canonical way to test to see if the process has administrative
Is there a way to test to see if javascript is enabled to ensure
In some existing code there is a test to see if the user is
If I reference the SnakeYAML jar directly from a test program (see bottom), everything

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.