Use the longer form of insert that names the fields, and don't try to fiddle the auto_increment field:
- Code: Select all
insert into interest (forename, surname, email, phone, comment)
values ('$_POST[F_NAME]', '$_POST[L_NAME]', '$_POST[email]',
'$_POST[PHONE]', '$_POST[REMARK]')
Not only is that clearer and more robust, but it will mean that your code will not break if you add a later (optionally supplied) column to the table later on.
Aside - your comment about addslashes noted. If your
PHP is configured with magic quotes on (it is that way by default) the you don't want to add slashes as you put things into the database. If it's configured with magic quotes off, it's important to add slashes and to do so before you release your page to the world or you'll be exposed to an injection attack.