mikebyrne Posted March 11, 2009 Share Posted March 11, 2009 When I click on my submit button I want all the data in the textboxes and option boxes to go into my DB I assume the command would be something like $sql="INSERT INTO Athy (Fname, Lname, ID) VALUES ('$_POST[firstname]','$_POST[lastname]','$_POST[iD]')"; Im just not sure how to modify my existing code to allow this my current code <? include("connect.php"); // now you are connected and can query the database ?> <html> <body> <form action="test.php" method="post"> <p><img src="untitled.jpg" alt="" width="994" height="176" /></p> <p>Id Number: <input type="text" name="ID" /> </p> <p>Station: <select name="Station"> <option value="AB1">Athy Boys Nat. School - Room 01</option> <option value="AB2">Athy Boys Nat. School - Room 02</option> <option value="AB3">Athy Boys Nat. School - Room 03</option> <option value="AB4">Athy Boys Nat. School - Room 04</option> <option value="AB5">Athy Boys Nat. School - Room 05</option> <option value="AB6">Athy Boys Nat. School - Room 06</option> <option value="AB7">Athy Boys Nat. School - Room 07</option> <option value="AB8">Athy Boys Nat. School - Room 08</option> <option value="SVH">Saint Vincent's Hospital, Athy</option> <option value="SMN1">Scoil Mhichil Naofa - Room 01</option> <option value="SMN2">Scoil Mhichil Naofa - Room 02</option> <option value="SMN3">Scoil Mhichil Naofa - Room 03</option> <option value="SNM4">Scoil Mhichil Naofa - Room 04</option> <option value="SNM5">Scoil Mhichil Naofa - Room 05</option> </select> <p> Firstname: <input type="text" name="Fname" /> </p> <p>Lastname: <input type="text" name="Sname" /> </p> <p> Address 1: <input type="text" name="Address1" /> </p> <p> Address 2: <input type="text" name="Address2" /> </p> <p>Division: <select name="Division"> <option value="AEU">Athy East Urban</option> <option value="AR">Athy Rural</option> <option value="AR2">Athy Rural (Inside U. D.)</option> <option value="AWU">Athy West Urban</option> </select> </p> <p>Vote: <select name="Vote"> <option value="U">Unknown</option> <option value="D">Dail, European Parliament and Local Elections only</option> <option value="E">European Parliament and Local Elections only</option> <option value="L">Local Elections only</option> <option value="S">Post or special arrangement only</option> </select> </p> <p> <input type="submit" /> </p> </form> </body> </html> <? //close the mysql connection mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/148897-solved-insert-into-table-on-sumbmit/ Share on other sites More sharing options...
tbare Posted March 12, 2009 Share Posted March 12, 2009 is that the code of test.php or are you posting to a different page? Link to comment https://forums.phpfreaks.com/topic/148897-solved-insert-into-table-on-sumbmit/#findComment-782616 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.