覆盖表单字段中的输入值

I have an "Update Profile" script that retrieves the details of the logged in user in a form input, so they can see what the current values are. Like this:

 <input type="text" name="first_name" id="first_name" value='<?= $row->f_name; ?>' title="enter your first name.">

This works. When users navigate to the page they see their first name appear in that input box. When they go to change their name and enter in a new value the form submits but keeps the original value and not the updated one. I assume that is because I am hard-coding a value to it with the value attribute.

How can I show the user the value in the input so that if they choose to not edit it, it does submit with the original value and not a blank, but if they do choose to add text to the input box the new string is submitted?

If I understand you correctly:

value="<?=set_value('first_name', $first_name)?>"

The first parameter is the posted value, the second parameter is the default overridden value.

`if($_GET['first_name']==''){

$first_name= $row->f_name;

}else{

$first_name= $_GET['first_name'];

}`

SQL Query :

"UPDATEyour_table_nameSETfirst_name= '$first_name' WHEREblablabla= '$blablalba';"

&ltinput type="text" name="first_name" id="first_name" value='f_name; ?>' title="enter your first name.">

You may want to use placeholder attributes.

<input type="text" name="first_name" placeholder="<?= $row->f_name; ?>">