preventing php from executing prematurely in html form script
I have made a form with the php code right under the html form code in the same file. In the php code section, the page will echo "please fill in all the fields" if the user does not fill in and submit all the important field data. Whats bugging me is that the "please fill in all the fields" message displays BEFORE the user even clicks the submit button. I don't want anything to echo out until after the开发者_JS百科 submit button is clicked, thanks.
thanks in advance.
You could try this
if(isset($_POST['submit'])){
echo "please fill in all the fields";
}
Where "submit" is the value of your submit button.
And maybe add something like && $_POST['important_field'] == ""
You really should have posted some actual code by the way. That would make it a bit easier. Nevertheless I think you can fix it with this.
精彩评论