I have an enquiry form, and on submit the info gets inserted into the database.
But, when I click the submit button, it doesnt seem to recognise the isset function so that the data gets inserted.
Here is all the code:
if (isset($_POST ['btnsubmit'])) {
// CODE FOR INSERTING DATA
$fname=$_POST['txtfname'];
$lname=$_POST['txtlname'];
$company=$_POST['txtcompany'];
$address=$_POST['txtaddress'];
$pcode=$_POST['txtpcode'];
$email=$_POST['txtemail'];
$tel==$_POST['txttel'];
$fax==$_POST['txtfax'];
mysql_query("insert into Register(FirstName,LastName,Company,Address,PostCode,Email,Tel,Fax) values('$fname','$lname','$company','$address','$pcode','$email','$tel','$fax')") or die ();
$flag=1;
$conf="Insert Data Successfully ";
}
And here is the form:
<form id="ajax-contact-form" method="post" name="form1" action="register.php?index=<?=$index?>" >
<p><input class="required inpt" type="hidden" name="to" value="" /></p>
<p><label>First Name :</label>
<input class="required inpt" type="text" name="txtfname" value="" />
</p>
<p><label>Last Name :</label>
<input class="required inpt" type="text" name="txtlname" value="" />
</p>
<label>Company :</label>
<input class="required inpt" type="text" name="txtcompany" value="" />
</p>
<label>Address :</label>
<textarea name="txtaddress" cols="3" rows=""></textarea>
</p>
<p><label>Post Code :</label>
<input class="required inpt" type="text" name="txtpcode" value="" />
</p>
<p><label>Email address :</label>
<input class="required inpt" type="text" name="txtemail" value="" />
</p>
<p>
<p>
<p><label>Tel :</label>
<input class="required inpt" type="text" name="txttel" value="" />
</p>
<p><label>Fax :</label>
<input class="required inpt" type="text" name="txtfax" value="" />
</p>
<p>
<p><label id="load"></label>
<input name="btnsubmit" type="image" class="submitbutton" src="images/submitbutton.png" value="Submit"/>
</p>
</form>
</fieldset>
I know its the isset bit, because when I take it away, fill in the form and click submit to refersh the page, the info gets uploaded to the database. But obviously I need it check first that the button has been clicked, rather than the page refreshed.
Cheers