skiingguru1611 Posted February 12, 2008 Share Posted February 12, 2008 I have MySQL client version: 5.0.37, running with PHPmyAdmin. I created a database, and a table inside of it, which I want data from an HTML form to be sent to and saved. On submit the data from the form goes to "insert.php" which looks like this: <? $username="myuser"; $password="mypass"; $database="dbname"; $first=$_POST['first']; $last=$_POST['last']; $address=$_POST['address']; $city=$_POST['city']; $state=$_POST['state']; $zipcode=$_POST['zipcode']; $phone=$_POST['phone']; $cell=$_POST['cell']; $email=$_POST['email']; $age=$_POST['age']; $weight1=$_POST['weight1']; $height1=$_POST['height1']; $grade=$_POST['grade']; $position=$_POST['position']; $school=$_POST['school']; $coach=$_POST['coach']; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO registration VALUES ('','$first','$last','$address','$city','$state','$zipcode','$phone','$cell','$email','$age','$weight1','$height1','$grade','$position','$school','$coach')"; mysql_query($query); mysql_close(); ?> <html> <body> <p>Submit Successful</p> </body> </html> The file works somewhat because I get the "Submit Successful" message back but when I check the Database, nothing is there. The table is called Registration and looks like: registration Field Type Null Default id int(4) No first varchar(20) No last varchar(20) No address varchar(30) No city varchar(20) No state varchar(15) No zipcode varchar(10) No phone varchar(15) No cell varchar(15) No email varchar(25) No age varchar(10) No weight1 varchar(15) No height1 varchar(20) No grade varchar(10) No position varchar(20) No school varchar(25) No level varchar(20) No coach varchar(30) No I am confident the problem lies in the "insert.php" file but I haven't a clue what that problem is, any help? Thank you. Quote Link to comment Share on other sites More sharing options...
peranha Posted February 12, 2008 Share Posted February 12, 2008 // create query $query = "INSERT INTO registrations (id, first, last, ) VALUES ('', '$first', $last', '$address', '$city', '$state', '$zipcode', '$phone', '$cell', '$email', '$age', '$weight1', '$height1', '$grade', '$position', '$school', '$coach')"; You forgot to put the field names from the table in after the registrations. I started, you should be able to finish it, just keep adding you fields with commas separating. Quote Link to comment Share on other sites More sharing options...
skiingguru1611 Posted February 12, 2008 Author Share Posted February 12, 2008 Thanks a bunch man, I had a feeling it was something kind of simple. It works, and again thank you soooooo much. Quote Link to comment Share on other sites More sharing options...
peranha Posted February 12, 2008 Share Posted February 12, 2008 no problem that is what this forum is for. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.