This is what my input form looks like:
<tr>
<td class="standard_text_bold" width="25%">First name:</td>
<td class="standard_text_bold" width="25%"><input type="text" name="FirstName" value="<?echo $Name;?>" <?php if ($Status != "New customer") { echo "disabled"; } ?>></td>
</tr>
<tr>
<td class="standard_text_bold" width="25%">Last name:</td>
<td class="standard_text_bold" width="25%"><input type="text" name="LastName" value="<?echo $Lastname;?>" <?php if ($Status != "New customer") { echo "disabled"; } ?>></td>
</tr>
<tr>
<td class="standard_text_bold" width="25%">Email:</td>
<td class="standard_text_bold" width="25%"><input type="text" name="Email" value="<?echo $Email;?>" <?php if ($Status != "New customer") { echo "disabled"; } ?>></td>
</tr>
It's very general, and in a specific case, almost all inputs will be disabled.
I define all my inputs as
$LastName = $_POST['LastName'];
$FirstName = $_POST['FirstName'];
And I run an update query
mysql_query("
UPDATE data SET
FirstName = '$FirstName',
LastName = '$LastName',
ProductName = '$Productname',
ProductPriceUSD = '$Productpriceusd',
ProductPriceEUR = '$Productpriceeur',
ProductLink = '$Productlink',
Status = '$Newstatus',
Modified = now()
WHERE ID = '$id'
") or die(mysql_error());
Now I'd like to update ONLY those values that are not empty. Since this is a general query, is it possible to validate variables within the query itself?
I've tried stuff like:
if (empty($_POST['LastName'])) {
$LastName = $row['LastName'];
}
if (!empty($_POST['LastName'])) {
$LastName = $_POST['LastName'];
}
But it doesn't work for some reason. Any suggestions?