user701510
user701510

Reputation: 5763

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 submit button is clicked, thanks.

thanks in advance.

Upvotes: 0

Views: 130

Answers (1)

Nanne
Nanne

Reputation: 64399

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.

Upvotes: 4

Related Questions