I ran into an interesting wall today working on a simple form with PHP and HTML and can't think of a quick fix.
I'm using the PHP script I've written when the user presses submit on my HTML page. In order to re-display the page after running the script I simply write
include "html_forms.html"
at the bottom of the PHP script. Firstly, this seems like a bad design for presenting the page as it needs to be constantly fully re-displayed but I couldn't figure out how to circumvent this problem.
The problem I'm more concerned with here though is that I'm trying to keep the form data from before the user first pressed submit by using PHP. To do this I modify the value of each input like this (within the HTML):
value = "<?php echo $website; ?>
However, when the webpage is first loaded from the HTML (I'm guessing it can't find the PHP to reference since the Submit button hasn't been clicked yet so) in my entry box on the page the first time it's loaded it prints <?php echo $website; ?>
. If I load the PHP first it doesn't have that problem but this schism makes me question the overall design that I'm going for and although it might fix the problem in this case it seems like it only works because the simplicity of the webpage.
My main question is how to fix this? I've thought of looking into just emptying the html entries on the first go and other techniques but I'm not sure if this would be the best approach since making special cases especially for the first time the page is clicked seems like bad form.
Thanks in advance for the help guys and this is the first question I've asked on stack-overflow so let me know if there's anyway I could improve my question-asking and don't be too harsh on me!