Jeff Voss
Jeff Voss

Reputation: 3695

Form field input empty than do not update

I have a form that updates a user's info. How can I tell the form to NOT update certain fields when left blank?

if(trim($email) == '') { /* don't update */ }

Upvotes: 0

Views: 2068

Answers (2)

rackemup420
rackemup420

Reputation: 1567

if(trim($email) == '') {}else{ YOUR UPDATE SCRIPT HERE }

Upvotes: 2

Nahydrin
Nahydrin

Reputation: 13517

This is better:

if ( empty( trim( $email ) ) )
{
    // do not update
}
else
{
    // update
    ...
}

Upvotes: 2

Related Questions