I have a php script which gets data from a DB (it works) but need to write the retrieved values to textboxes in an HTML form (pure html form, no php). How do I reference the html file and its text boxes from my PHP script?
1 Answer
PHP is exactly for that purpose. You can not make a webpage dynamically with just HTML. You would achieve what you want when "print" a PHP Variable in an HTML input field.
So you create a .php file and write down your HTML. And when you want your variable in your fields you do this:
<input value="<?= $yourVariableName; ?>">
That's the ways how you can print PHP variables into HTML.
1 Comment
user3586157
Thanks everyone. Actually I realised that and changed the page to a php file! However it might be best if I explain the problem further. My form allows users to (1) Enter new details to a DB. This works, no probs. (2) Update their existing details. They enter their club name in a text box and hit a button which retrieves their details into the form's textboxes. All processing is carried out in another PHP file (process.php). How do I get the results in process.php into the textboxes in the PHP file that contains the form? I have set up a PHP session in both files.
value="<?= $yourVariable ?>"), or you need to get the values using Ajax and populate the form using js.