title: Stop Submit With Empty Input Values Using PHP
body: <p>I'm looking for a simple PHP solution to stop empty input values at form from submitting empty input fields. The code for the form is below. I would like to use a simple PHP (non-Javascript) solution if possible.</p>
  
  <p><code>Form.php</code> code:</p>
  
  <pre><code>&lt;form name="form" method="post" action="add.php"&gt;
  &lt;input type="text" name="url" id="url"&gt;
  &lt;button type="submit" id="submit"&gt;submit&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><code>add.php</code> code:</p>
  
  <pre><code>$url=$_POST['url'];
  $sql= "insert into my_table set url='$url'";
  mysql_query($sql) or die("query failed: $sql".mysql_error());
  $msg= 'URL Added Thank You';
  session_register('msg');
  header("Location: form.php ");
  exit;
  </code></pre>
  
  <p>If there any PHP solution to prevent empty input submit before form submit or after submit so it can send me back to <code>form.php</code>.</p>
  
  <p>Thank you.</p>