0

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?

2
  • You either need to change your html file to a php file and echo the variables in the inputs value-attribute (like this: value="<?= $yourVariable ?>" ), or you need to get the values using Ajax and populate the form using js. Commented Jan 18, 2019 at 17:13
  • 1
    Start to learn PHP? Commented Jan 19, 2019 at 0:47

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.