I am using a simple form and submitting my textbox values to database,
<body>
<?php
if(isset($_POST["submit"]))
$des="Insert into enquiry(Companyname,Name,Phno,Email,Address,Comments) values
('".$_POST[txtcompname]."','".$_POST[txtname]."','".$_POST[txtphno]."',
'".$_POST[txtemail]."','".$_POST[txtaddress]."','".$_POST[txtcomments]."')";
$res1=mysql_query($des);
?>
<div align="left">
<form action="" method="post">
But it doesn’t seem to get submitted? Any suggestion
When i use print_r($_POST); i get
Array ( [txtcompname] => xv [txtname] => xcv [txtphno] => xcvx [txtemail] => xcv [txtaddresss] => xcv [txtcomments] => xcvxcv [submit] => submit )
and i get this error now,
You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'Address,Comments)
values ('zdc','sadcv','zdsv', 'sdcv','sdvcsdv','sdcv')' at line 2
i found a few mistakes in your code just by regarding it… make sure you have all warning on so you could see them
1) Brackets after the if, or else only the assignation of the $des variable will be executed when the form is submitted
2) $_POST is an array.. you need the quotes $_POST[‘txtcompname’]
finally make sure that the submit input has
name="submit",although i think it’s better to evaluate the submit by usingif !empty($_POST)good luck