[Solved] Retrieve data from database and display in text boxes [closed]


I’ll give a very simple example that should get you started.

The values are accessible via (most likely) $_POST['input_name']. Without using Post/Redirect/Get, you can just get the input values like:

$input_name = isset($_POST['input_name']) ? $_POST['input_name'] : '';

Then later you’ll display it in the form like:

echo '<input name="input_name" value="'
    . htmlspecialchars($input_name, ENT_QUOTES) . '">';

If you want to use P/R/G, which you should do, you need to store the input in the $_SESSION.

session_start();
//initialize all inputs to the empty string
if (!isset($_SESSION['inputs'])) {
    $_SESSION['inputs'] = array('input_name' => '');
}
if ('POST' == $_SERVER['REQUEST_METHOD']) {
    $_SESSION['inputs']['input_name'] = isset($_POST['input_name']) /* etc. */;
}

You can then output it in your form via $_SESSION instead of $_POST.

solved Retrieve data from database and display in text boxes [closed]