Form submitting but mysql query not properly functioning : <p>The following code gives a signup form that i created but unfortunately though it works the mysql query fails and returns the error message unsuccessfull signup! how can i correct this?</p>

<pre><code>    &lt;!DOCTYPE html&gt;
    &lt;html lang="en"&gt;
    &lt;head&gt;
      &lt;!-- Theme Made By www.w3schools.com - No Copyright --&gt;
      &lt;title&gt;Arsiri Textile &lt;/title&gt;
      &lt;meta charset="utf-8"&gt;
&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
  &lt;!-- Theme Made By www.w3schools.com - No Copyright --&gt;
  &lt;title&gt;Arsiri Textile &lt;/title&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
  &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"&gt;
  &lt;link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet" type="text/css"&gt;
  &lt;link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css"&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;link rel="stylesheet" type="text/css" href="css/basic.css"&gt;
  &lt;style&gt;

  &lt;/style&gt;
&lt;/head&gt;
&lt;body id="myPage" data-spy="scroll" data-target=".navbar" data-offset="60"&gt;




&lt;div class="header" style="height:60px;background:#330d00;width:1350px"&gt;


      &lt;a class="navbar-brand" href="#myPage"&gt;ARSIRI TEXTILE |&lt;/a&gt;


      &lt;ul class="nav navbar-nav navbar-left"&gt;


      &lt;/ul&gt;
      &lt;ul class="nav navbar-nav navbar-right"&gt;

        &lt;li&gt;&lt;a href="#"&gt;About Us&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="#"&gt;Contact Us&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=""&gt;Login&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="#"&gt; Signup&lt;/a&gt;&lt;/li&gt;

      &lt;/ul&gt;
    &lt;/div&gt;


&lt;div class="image" style="height:530px; width:1350px" &gt;
    &lt;!doctype html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" /&gt;
&lt;link rel="stylesheet" type="text/css" href="css/bootstrap-theme.min.css" /&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;div class="panel panel-default"&gt;
 &lt;div class="panel-heading" style="background:#330d00;"&gt;
  &lt;h3 class="panel-title"&gt;Customer Registration&lt;/h3&gt;&lt;br&gt;
 &lt;/div&gt;
  &lt;div class="panel-body" &gt;
 &lt;form class="form-horizontal" role="form" action="signupaction.php" method="post" &gt; 
  &lt;div class="form-group"&gt;
    &lt;label for="name" class="col-sm-2 control-label"&gt;First Name&lt;/label&gt;
    &lt;div class="col-sm-10" style="width:300px"&gt;
      &lt;input type="text" class="form-control" id="name" name="firstname" required&gt;
    &lt;/div&gt;
  &lt;/div&gt;

      &lt;div class="form-group"&gt;
    &lt;label for="name" class="col-sm-2 control-label"&gt;Last Name&lt;/label&gt;
    &lt;div class="col-sm-10" style="width:300px"&gt;
      &lt;input type="text" class="form-control" id="name" name="lastname" required&gt;
    &lt;/div&gt;
  &lt;/div&gt;
      &lt;div class="form-group"&gt;
    &lt;label for="Address" class="col-sm-2 control-label"&gt;Address&lt;/label&gt;
       &lt;div class="col-sm-10" style="width:300px"&gt;
           &lt;textarea class="form-control" class="form-control" name="address"&gt;&lt;/textarea&gt;

    &lt;/div&gt;
  &lt;/div&gt;
&lt;div class="form-group"&gt;
    &lt;label for="name" class="col-sm-2 control-label"&gt;Contact No.&lt;/label&gt;
    &lt;div class="col-sm-10" style="width:300px"&gt;
      &lt;input type="text" maxlength="10" class="form-control" id="name" name="contactno" required&gt;
    &lt;/div&gt;
  &lt;/div&gt;
   &lt;div class="form-group"&gt;
    &lt;label for="name" class="col-sm-2 control-label"&gt;E-Mail&lt;/label&gt;
    &lt;div class="col-sm-10" style="width:300px"&gt;
      &lt;input type="email" class="form-control" id="name" name="emailaddress" required&gt;
    &lt;/div&gt;
  &lt;/div&gt;





    &lt;div class="form-group"&gt;
    &lt;label for="password" class="col-sm-2 control-label"&gt;Password&lt;/label&gt;
       &lt;div class="col-sm-10" style="width:300px"&gt;
      &lt;input type="password" class="form-control" id="pass" name="password" required&gt;
    &lt;/div&gt;
  &lt;/div&gt;
    &lt;div class="form-group"&gt;
    &lt;label for="password" class="col-sm-2 control-label"&gt;Confirm password
    &lt;/label&gt;
       &lt;div class="col-sm-10" style="width:300px"&gt;
      &lt;input type="password" class="form-control" id="confirmpass" name="cpassword" required&gt;&lt;br&gt;
    &lt;/div&gt;
  &lt;/div&gt;
     &lt;div class="panel-footer" style="overflow:hidden;text-align:left;"&gt;   

    &lt;div class="col-sm-offset-2 col-sm-10"&gt;
        &lt;input class="btn btn-success btn-sm" type=submit name=submit value=Submit &gt;
&lt;input class="btn btn-success btn-sm" type=reset name=reset value=Cancel&gt;

    &lt;/div&gt;
&lt;/form&gt;





    &lt;/div&gt;
  &lt;/div&gt;  
  &lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;

&lt;/div&gt;




&lt;div class="footer " style="background:#330d00; height:60px ;width:1350px "&gt;
 &lt;p align="center" &gt; Asiri all rights reserved&lt;/p&gt;
&lt;/div&gt;
</code></pre>

<p>The relevant php script(ignupaction.php) for the above html form is as follows</p>

<pre><code>&lt;?php

//importing db.php in the includes folder

require("includes/db.php");


$fname=$_POST["firstname"];
$lname=$_POST["lastname"];

$address=$_POST["address"];
$contact=$_POST["contactno"];
$email=$_POST["emailaddress"];

$password=$_POST["password"];
$cpassword=$_POST["cpassword"];



$sql="INSERT INTO `signup`  VALUES ('$fname','$lname','$address','$contact','$email','$password',$cpassword')";



$result=mysqli_query($db,$sql);

if(!$result){
    echo "Unsuccessful signup";
}
else{
    echo "Successful signup";
}




?&gt;
</code></pre>

<p>when the form is submitted it returns unsuccessful signup! how can i correect this?</p>
