Jump to content

[SOLVED] Insert into table on sumbmit


mikebyrne

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.