I used the folowing website towards the end of the website http://zetcode.com/databases/sqlitephptutorial/ to make a connection to the sqlite database using PHP. Working on netbeans and have imported the appropriate driver and jar files however clicking submit on html is not doing the job and simply prints the whole php file.

Heres my html and php...

<?php




$id= (int)rand(1,9999999);
$name = $_POST['name'];
$CompanyName = $_POST['CompanyName'];
$number = $_POST['number'];
$Address = $_POST['Address'];
$Emailaddress = $_POST['Emailaddress'];
$pwd = $_POST['pwd'];
$business = $_POST['business'];
$Monthlyspend = $_POST['Monthlyspend'];
$products = $_POST['products'];
$industry = $_POST['industry'];
$customers = $_POST['customers'];
$info = $_POST['info'];



$name_es = sqlite_escape_string($name);

if (!empty($name)) {

   $dbhandle = sqlite_open('RegisterNewcustomer', 0666, $error);

   if (!$dbhandle) die ('Could not find database');

   $stm = "INSERT INTO Registercustomers(ID,name,CompanyName,number,EmailAddress,business,Monthlyspend,products,customers,info,password,industry) VALUES('$id', '$name_es', '$CompanyName', '$number', '$Address', '$Emailaddress', '$business', '$Monthlyspend', '$products', '$customers', '$info', '$pwd', '$industry')";
   $ok = sqlite_exec($dbhandle, $stm, $error);

   if (!$ok) die("Error: Cannot Execute Query");  
   echo "Form Submitted Successfully";
}


?>




   <!DOCTYPE html>
<html>
    <head>
        <title>Register New account </title>
    </head>
    <body>
        <h1> Register a New Account </h1>
        <p> To register a new Account, Please fill in the form below alternatively you can call the customer services team<br />
             at Alliance Healthcare at <strong>020 8391 2323</strong> to enquire about opening a new account.<br />
           </p>
       <form name="RegisterNewaccount" method="POST" action="form.php">
               <fieldset>
               <legend>
                   Your Details:
               </legend>
<p><label> Name:<br>
  <input type="text" name="name" size="30" maxlength="50"/></label> </p><br> 
 <p> <label> Company Name: <br>
 <input type="text" name="CompanyName" size="30" maxlength="50"/> </label></p> <br>
  <p> <label> Contact Number:<br>
 <input type="text" name="number" size="30" maxlength="50"/></label> </p><br>
 <p> <label> Address:<br>
  <input type="text" name="Address" size="30" maxlength="50"/> </label> </p><br>
   <p>  <label>  Please enter a valid Email Address: <br>
   <input type="text" name="Emailaddress"> </label></p> <br>
   <p>  <label>  Please Choose a Password: <br><input type ="password" name="pwd"/> </label> </p><br>
   <p>  <label> Type of Business:</label> <br> 
   <select name="business">
   <option value="Community pharmacy">Community Pharmacy </option>
  <option value="Hospital Pharmacy">Hospital Pharmacy</option>
  <option value="Dispensing Doctor"> Dispensing Doctors</option>
  <option value="Non Pharmacy/Wholesaler">Non Pharmacy/Wholesaler</option>
  </select>  </p>
  <p> <label> Approximately how much would your monthly spend be:<br><input type="text" name="Monthlyspend"> </label> </p><br>
   <p>  <label>What products are you interested in purchasing:</label> </p>
  <input type="checkbox" name="products" value="Almus"/> Almus
  <input type="checkbox" name="products" value="Health and Beauty Products"/> Health & Beauty Products
  <input type="checkbox" name="products" value="Prescription Medicine"/> Prescription Medicine <br> 
  <p><label>  What sector of the industry do you operate in? :<br> <input type="text" name="industry"> </label> </p> <br>
    <p>  <label>  Who are your customers? </label></p>
   <textarea rows="4" cols ="20" name="customers"> </textarea> 
   <p>  <label>How did you find out about Alliance Healthcare ? </label> <br>
   <textarea rows="3" cols="50" name="info"> </textarea></p> 
   <input name="Submit" type="submit" value="Submit" />
            </fieldset>
        </form>
    </body> 
</html>

I assume you have database and tables defined. Also I assumen names of column in INSERT query are correct and case sensitive. Try using PDO instead of that one.

Amny advantages for using PDO especially its prepared statement. Here is sample code:

    <?php
    if(isset($_POST['name']))
    {

        $id= (int)rand(1,9999999);
        $name = $_POST['name'];
        $CompanyName = $_POST['CompanyName'];
        $number = $_POST['number'];
        $Address = $_POST['Address'];
        $Emailaddress = $_POST['Emailaddress'];
        $pwd = $_POST['pwd'];
        $business = $_POST['business'];
        $Monthlyspend = $_POST['Monthlyspend'];
        $products = $_POST['products'];
        $industry = $_POST['industry'];
        $customers = $_POST['customers'];
        $info = $_POST['info'];

        //$dbhandle = new SQLite3('RegisterNewcustomer.db');
        try{
            $dbhandle = new PDO('sqlite:host=RegisterNewcustomer.db');
            }
        catch (PDOException $error) {
            echo 'error connecting to file! error message: ', $error->getMessage(), '<br/>';
        }

        if (!$dbhandle) die ('Could not find database');
        $sql = "INSERT INTO Registercustomers(ID,name,CompanyName,number,EmailAddress,business,Monthlyspend,products,customers,info,password,industry) VALUES('$id', '$name', '$CompanyName', '$number', '$Address', '$Emailaddress', '$business', '$Monthlyspend', '$products', '$customers', '$info', '$pwd', '$industry')";
        die($sql);
        $ok = $dbhandle->exec( $sql);
        if (!$ok) die("Error: Cannot Execute Query");
        echo "Form Submitted Successfully"; 
    }
    ?>
    <!DOCTYPE html>
    <html>
    <head>
    <title>Register New account </title>
    </head>
    <body>
    <h1> Register a New Account </h1>
    <p> To register a new Account, Please fill in the form below alternatively you can call the customer services team<br />
    at Alliance Healthcare at <strong>020 8391 2323</strong> to enquire about opening a new account.<br />
    </p>
    <form name="RegisterNewaccount" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <fieldset>
    <legend>
    Your Details:
    </legend>
    <p><label> Name:<br>
    <input type="text" name="name" size="30" maxlength="50"/></label> </p><br>
    <p> <label> Company Name: <br>
    <input type="text" name="CompanyName" size="30" maxlength="50"/> </label></p> <br>
    <p> <label> Contact Number:<br>
    <input type="text" name="number" size="30" maxlength="50"/></label> </p><br>
    <p> <label> Address:<br>
    <input type="text" name="Address" size="30" maxlength="50"/> </label> </p><br>
    <p> <label> Please enter a valid Email Address: <br>
    <input type="text" name="Emailaddress"> </label></p> <br>
    <p> <label> Please Choose a Password: <br><input type ="password" name="pwd"/> </label> </p><br>
    <p> <label> Type of Business:</label> <br>
    <select name="business">
    <option value="Community pharmacy">Community Pharmacy </option>
    <option value="Hospital Pharmacy">Hospital Pharmacy</option>
    <option value="Dispensing Doctor"> Dispensing Doctors</option>
    <option value="Non Pharmacy/Wholesaler">Non Pharmacy/Wholesaler</option>
    </select> </p>
    <p> <label> Approximately how much would your monthly spend be:<br><input type="text" name="Monthlyspend"> </label> </p><br>
    <p> <label>What products are you interested in purchasing:</label> </p>
    <input type="checkbox" name="products" value="Almus"/> Almus
    <input type="checkbox" name="products" value="Health and Beauty Products"/> Health & Beauty Products
    <input type="checkbox" name="products" value="Prescription Medicine"/> Prescription Medicine <br>
    <p><label> What sector of the industry do you operate in? :<br> <input type="text" name="industry"> </label> </p> <br>
    <p> <label> Who are your customers? </label></p>
    <textarea rows="4" cols ="20" name="customers"> </textarea>
    <p> <label>How did you find out about Alliance Healthcare ? </label> <br>
    <textarea rows="3" cols="50" name="info"> </textarea></p>
    <input name="Submit" type="submit" value="Submit" />
    </fieldset>
    </form>
    </body>
    </html>

Something strikes me as strange about your question, not to seem rude, but if the whole thing is being printed,
then you are not using a browser and php interpreter. If that were the case the php would not be printed, check those things before driving yourself crazy trying to fix code that looks essentialy correct.

I tried your exact code in xampp on my machine, and, aside from me not having the correct table structure in the dbase and you need the suffix .db or .sqlite on your dbase name, it works fine. Unless you have php installed and a developement server you won't see the correct results. Try xampp or a similar wamp stack (assuming you are on windows) or a lamp stack if you are on linux.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.