RE: [PHP-DB] Not updating certain fields in same row

[email protected] (Miguel Guirao)
Newsgroups php.db
Organization RADIOMOVIL DIPSA, S.A. DE C.V.
Message-ID <[email protected]>
You can't use the function empty() because as soon as the form is submitted,
the value of an empty field in the form, is a blank in the variable in your
script, so basically your password field is NOT empty, it has a value, a
blank.

So you need to test your password field to NOT to be empty, also use a
second password field, a confirmation field, so:

$querystring="your SQL statement here";
If (passwd1 is not blank) and (passwd1==passwd2) then
	$querystring.="passwd='passwd1'"
If not
	You keep intact your first SQL statement without touching the passwd
field

My two niquel cents!
__________________
Miguel Guirao Aguilera, Linux+, ITIL
Sistemas de Información
Informática R8
Ext. 7540

--> -----Original Message-----
--> From: Jason Pruim [mailto:[email protected]]
--> Sent: Tuesday, March 25, 2008 11:14 AM
--> To: Daniel Brown
--> Cc: [email protected]
--> Subject: Re: [PHP-DB] Not updating certain fields in same row
--> 
--> 
--> On Mar 25, 2008, at 1:09 PM, Daniel Brown wrote:
--> > On Tue, Mar 25, 2008 at 12:59 PM, Jason Pruim <[email protected]>
--> > wrote:
--> >> Hi everyone,
--> >>
--> >> I am attempting to update a record for a login system while leaving
--> >> certain fields untouched if they arn't changed, and am running into
--> >> issues.
--> > [snip!]
--> >>
--> >> I have tried this code:
--> >>                $tab = "\t";
--> >>        if (!isset($_POST['txtLoginName']) ||
--> >> empty($_POST['txtLoginName'])) {
--> >>
--> >>                        $loginName =
--> >> mysqli_real_escape_string($chpwpostlink,
--> >> $_POST['txtLoginName']);
--> >>                }
--> >>                else
--> >>                {
--> >>                        $loginName = $tab;
--> >>                }
--> >
--> >    Mmm-hmm.... and exactly how do that work to update the database?
--> > The SQL query you're probably looking for would be like this:
--> >
--> >    $sql = "UPDATE users SET
--> > Field1
--> > =
--> > '".mysql_real_escape_string
--> > ($field1)."',Field3='".mysql_real_escape_string($field3)."'
--> > WHERE id='".mysql_real_escape_string($id)."' LIMIT 1";
--> 
--> the actual query I'm using is this:
--> 
--> 	$chpwsql = "UPDATE current SET customerName='$customerName',
--> loginName='$loginName', loginPassword='$PW', email='$email',
--> adminLevel='$adminLevel' WHERE Record='$Record1'";
--> 
--> What it is doing now is if I don't set a a field I am replacing the
--> content of it with a tab, which isn't what I want. Basically what I'm
--> looking for is if loginPassword hasn't changed... don't clear the
--> contents of it. if it has changed, then update loginPassword
--> 
--> 
--> >
--> >
--> > --
--> > </Daniel P. Brown>
--> > Forensic Services, Senior Unix Engineer
--> > 1+ (570-) 362-0283
--> >
--> > --
--> > PHP Database Mailing List (http://www.php.net/)
--> > To unsubscribe, visit: http://www.php.net/unsub.php
--> >
--> >
--> 
--> --
--> 
--> Jason Pruim
--> Raoset Inc.
--> Technology Manager
--> MQC Specialist
--> 3251 132nd ave
--> Holland, MI, 49424-9337
--> www.raoset.com
--> [email protected]
--> 
--> 
--> 
--> 
--> --
--> PHP Database Mailing List (http://www.php.net/)
--> To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.