PHP/HTML form adding to SQL Database?

Hey,

So im new to PHP, HTML and SQL :P...I made a form (using html, and then php to connect to the databse..im sure you know what i mean >.<) and everything is good...

i dont know if they way i am doing this is the average way everyone does it...but its how my friend set it up for me :)

Ok so what i do...i have a php document that i put up on his hosting site (via ftp)...open it, and my form pops up...all is good. except that when ever the .php document is opened, it adds a new record (just a blank record) and then i fill in the form and hit submit and it adds the record i want (this part works) ...i was looking in the sample code he gave me, and saw this line:

if($submit=="new"){ $sql = ("insert into roster set first='$first',...etc);

...i tried that in my code and it didnt work..it just makes it so that i cant add a new record (whether t be by opening the php doc or hittin submit...so how do i make it so that it ONLY adds a new record if the submit button is pressed?

so my question is..how do i make it work so that it only adds a new record if i hit the submit button?

Thanks
 
Back
Top