RSS Forums RSS
Please support our PHP advertiser: Lunarpages PHP Web Hosting

survey for school grads... Another question

Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 9
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: survey for school grads... Another question

  #2  
Jan 14th, 2008
  1. CREATE TABLE test (
  2. id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
  3. name VARCHAR( 100 ) NOT NULL ,
  4. address VARCHAR( 100 ) NOT NULL
  5. ) ENGINE = InnoDB
If that's my table, and I have a form with 2 fields name and address, this is how I would be inserting the values to the table test. This should get you started.(I hope!)
  1. <?php
  2. if(isset($_POST['submit'])){
  3. $conn=mysql_connect("localhost","root");
  4. mysql_select_db("exact");
  5. $name=$_POST['name'];
  6. $address=$_POST['address'];
  7. $query="INSERT INTO TEST (ID,NAME,ADDRESS) VALUES ('','$name','$address')";
  8. mysql_query($query);
  9. }
  10. ?>
  11. <html>
  12. <body>
  13. <form method="post" action="insert_example.php">
  14. Enter Name: <input type="text" name="name"><br />
  15. Enter Address: <textarea rows="10" cols="20" name="address"></textarea>
  16. <br />
  17. <input type="submit" name="submit" value="submit">
  18. </form>
  19. </body>
  20. </html>

Cheers,
Nav
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 11:18 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC