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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:48:22+00:00 2026-05-27T16:48:22+00:00

This starts when a user fills out a form with optional inputs. The values

  • 0

This starts when a user fills out a form with optional inputs. The values are passed by AJAX to another PHP page to insert into a database. If a particular input is empty, I don’t want to update the data stored in the database. Is there a way to check, besides writing lots of if statements, to see if an input value is empty? If it is empty, how can I write the statement so MySQL won’t update the corresponding field in the database?

if(isset($_POST['f_name']) && isset($_POST['m_name']) && isset($_POST['l_name']) && isset($_POST['alt_name'])){
    $fname = $_POST['f_name'];
    $mname = $_POST['m_name'];
    $lname = $_POST['l_name'];
    $altname = $_POST['alt_name'];

If some of the $_POST entries are empty, then they shouldn’t be put into the database. I’m saying this because if there’s already an existing value in the database, I don’t want to overwrite the value with an empty one.

  • 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-27T16:48:22+00:00Added an answer on May 27, 2026 at 4:48 pm

    In this case you also don’t allow people to enter just a blank space / &bnsp;

    <?php
    $empty = FALSE;
    
    foreach ($_POST as $key)
    {
        if (!isset($key) || strlen(trim($key)) != 0)
        {
          $empty = TRUE;
        }
    }
    
    if (!$empty)
    {
        $fname = $_POST['f_name'];
        $mname = $_POST['m_name'];
        $lname = $_POST['l_name'];
        $altname = $_POST['alt_name'];
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got an ASP.NET page with a simple form. The user fills out the
I have a form a user fills in and the action page it goes
I'm trying to use php with mysql. basically i've an index page where user
When you create a form element with CakePHP like so: echo $this->Form->input('User.first_name'); You start
I'm trying to figure out why this is happening. I'll have the user be
I have a ClickOnce environment like this: \\Fileserver\ClickOnceApps\App1.application C:\Documents and Settings\user\Start Menu\Programs\publisher\app1.appref-ms My understanding
This question kind of starts where this question ends up. MATLAB has a powerful
Array starts like this: Array ( [SMART Board] => Array ( [0] => sb1
My ASP.NET always starts like this with the internal server: http://localhost:50793/Website/ I use FckEditor
I have an XML file that starts like this: <Elements name=Entities xmlns=XS-GenerationToolElements> I'll have

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.