Note that there are some explanatory texts on larger screens.

plurals
  1. POForm submits even when all fields aren't filled out
    text
    copied!<p>I'm new to php and I don't quite understand why this form is submitting under all circumstances... So my question is:</p> <p>How do I fix this so the form only submits when the user fills out all fields?</p> <pre><code>if (!$_POST['username'] &amp;&amp; !$_POST['password'] &amp;&amp; !$_POST['repassword'] &amp;&amp; !$_POST['user_firstname'] &amp;&amp; !$_POST['user_lastname'] ){ header('Location: register.php?msg=You did not complete all of the required fields'); } </code></pre> <p>I used both <code>&amp;&amp;</code> and <code>||</code> operators however it always submits no matter what field you filled out. </p> <pre><code>&lt;form action="createuser.php" method="post" name="registration_form" id="registration_form"&gt; &lt;label&gt;Email&lt;/label&gt; &lt;input name="username" type="text" id="username" size="50" maxlength="50" /&gt;&lt;br /&gt; &lt;label&gt;First Name&lt;/label&gt; &lt;input name="user_firstname" type="text" id="user_firstname" size="50" maxlength="50" /&gt;&lt;br /&gt; &lt;label&gt;Last Name&lt;/label&gt; &lt;input name="user_lastname" type="text" id="user_lastname" size="50" maxlength="50" /&gt;&lt;br /&gt; &lt;label&gt;Password&lt;/label&gt; &lt;input name="password" type="password" id="password" size="50" maxlength="100" /&gt;&lt;br /&gt; &lt;label&gt;Re-type Password&lt;/label&gt; &lt;input name="repassword" type="password" id="repassword" size="50" maxlength="100" /&gt;&lt;br /&gt; &lt;input type="submit" value="Register" name="submit" /&gt; </code></pre> <p>Thanks in advance for any help, and this seems like an awesome community to be involved in!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload