开发者

replace input field with data from mysql php

I created this layout of successive text input fields, 1- Enter data into empty fields 2- Click on button which submits to a p开发者_C百科hp page that updates into database

Now the problem is that i want when i return to the main page again the empty field is replaced with data just added but there are still other empty fields to enter new data. How can i establish that?

Thanks in advance.


You haven't given a lot of detail but here goes!

You could build your inputs like this:

<input type="text" name="age"  value="<?php echo $age;  ?>">

When the form first loads, it won't have values for variables like $age, so the input will appear empty. Have the form submit via POST to the same PHP file, run your validation checks, and if everything passes, insert into to your database. (Is it required that you write to the database at this point, or should it wait until the second section is filled out?)

You'll need to use some kind of conditional statement to display the second part of the form. Depending on how complex this is, or whether users will be returning later, you could:

  1. Read the data back out of the database to check for completeness, and then display the second part.
  2. Set a variable to track what stage of the form you're in, and based on that, display different sections to be completed.

If you have a way of tracking what stage of the process you're in, you could do something like this:

$formStage = 2;
function isReadOnly($formStage='')
{
    if ($formStage == 2) {echo 'READONLY';}
}

and then in your HTML:

<INPUT NAME="realname" VALUE="Hi There" <?php isReadOnly($formStage)?>>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜