I have created an update form in PHP that takes the attributes of a tuple. The following query updates a tuple of the table based on the input:
<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
if(isset($_POST['submit'])) {
$sql = "UPDATE member SET MFirst='".$_POST["MFirst"]."', MLast='".$_POST["MLast"]."',Street='".$_POST["Street"]."'
,number='".$_POST["number"]."',postalCode='".$_POST["postalCode"]."',Mbirthdate='".$_POST["Mbirthdate"]."'
WHERE memberID='".$_POST["memberID"]."'";
$result = mysqli_query($conn,$sql);
}
?>
However, if not all attributes are submitted the update does not happen. How should I write the query in order to change an attribute of a tuple even if not all the attributes of the form are completed.
The form is the following:
<FORM METHOD="post" ACTION="update.php">
<div class="input-group">
<label>Member Id</label>
<INPUT TYPE="text" name="memberID" SIZE="30">
</div>
<div class="input-group">
<label>First Name</label>
<INPUT TYPE="text" name="MFirst" SIZE="30">
</div>
<div class="input-group">
<label>Last Name</label>
<INPUT TYPE="text" name="MLast" SIZE="30">
</div>
<div class="input-group">
<label>Street Name</label>
<INPUT TYPE="text" name="Street" SIZE="30">
</div>
<div class="input-group">
<label>Street Number</label>
<INPUT TYPE="number" name="number" min=0 SIZE="30">
</div>
<div class="input-group">
<label>Postal Code</label>
<INPUT TYPE="number" name="postalCode" min=0 SIZE="30">
</div>
<div class="input-group">
<label>Birth Day</label>
<INPUT TYPE="date" name="Mbirthdate" SIZE="30">
</div>
<button class="btn" TYPE="submit" name="submit">Submit Info </button>
<button class="btn" TYPE="reset" name="Reset">Reset </button>
</FORM>