Can you all help me with the approach I need to take once the user has submitted his data, I want those certain fields to be read-only permanently for that user upon submit.
So far I am able to save the data to MYSQL DB on submit and the below code also keeps the data in the field. But on refresh, the data in the form field disappears. How do I solve this? Any help and suggestions are greatly appreciated. Thank you.
<label class="control-label col-sm-2" for="lname">Last Name*</label> <input type="text" class="form-control" id="lastname" placeholder="Last Name" name="lastname" value="<?php if(isset($_POST['lastname'])) {echo htmlentities($_POST['lastname']);}?>" autocomplete="nope" required/>
Its very simple just add readonly into your input filed.
<input type='text' value='Test' id='test1' readonly>
do one thing in your database table keep a field for flag and then set a value for it like Active or Deactive then at the time of submitting the data check the user is exist or not if exist then do disable to the input fields like
SELECT * FROM users WHERE status
LIKE 'Active';
execute this query accordingly u set the input fields readonly
You might need javascript to do the trick. The trigger being clicking the submit button and change the readonly attribute to true as shown below.
jQuery <1.9
$('#relevantId').attr('readonly', true);
jQuery 1.9+
$('#relevantId').prop('readonly', true);