Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to tell if a user has left part of a form blank
    primarykey
    data
    text
    <p>i have created a php page that allows users to enter different products in my database. I have set up different validations that work correctly but can not figure out how to tell if the user has left part of the form blank or the whole thing blank. They have three text boxes, on for the id, item, and cost. Does anyone know how I could go about seeing if each one of these text boxes are blank? Thanks</p> <pre><code>&lt;!-- To change this template, choose Tools | Templates and open the template in the editor. --&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;title&gt;Adding Products&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;?php $db_server = "server"; $db_username = "name"; $db_password = "pass"; $con = mysql_connect($db_server, $db_username, $db_password);if (!$con) { die('Could not connect: ' . mysql_error()); } $database = "Product"; $er = mysql_select_db($db_username); if (!$er) { print ("Error - Could not select the database"); exit; } $tbl_name ="Product"; $ProductCode=$_POST['ProductCode']; $Description=$_POST['Description']; $Price=$_POST['Price']; $ProductCode=mysql_real_escape_string($ProductCode); $Description=mysql_real_escape_string($Description); $Price=mysql_real_escape_string($Price); $status = "OK"; if(strlen($ProductCode)&gt;10) { echo('Your product code can only be a max of ten characters&lt;BR&gt;'); $status= "NOTOK"; } if(strlen($Description)&gt;40) { echo('Your description of the product can only be 40 characters&lt;BR&gt;'); $status ="NOTOK"; } if(is_float($Price)) { $english_format_number = number_format($Price); //Changing number to floating point //echo ('Your number must be in floating point.&lt;BR&gt;'); //$status ="NOTOK"; } if($status&lt;&gt;"OK") { echo('Some of your inputs were not in the correct format.&lt;BR&gt;'); } else { $sql="INSERT INTO $tbl_name(Product_Code, Description, Price)VALUES('$ProductCode', '$Description', '$Price')"; $result=mysql_query($sql); echo ('Your items have been inserted into the databae.'); } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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