|  | Posted by Lars Eighner on 06/17/07 00:22 
In our last episode, <1182022780.799807.299250@q69g2000hsb.googlegroups.com>,
 the lovely and talented Cigar2011
 broadcast on comp.lang.php:
 
 > I will try to be short and to the point.(good Luck)  I have a form
 > written in HTML. I have a Mysql database. I am using a linux server
 > and I would like to use php to write the following code:
 
 > After the user inputs their name, address, email, phone, etc. in my
 > html form. They will hit the submit button. I need for the information
 > they entered to go into my database.
 
 > I have looked now for about 12 hours and haven't been able to find an
 > answer.
 
 What answer?  It seems you want the whole thing done for you, like it
 is homework.  What is the problem you are having?  Are you unable
 to get the data to your form handler?  Funny because although this
 has a few more variables, it is exactly like "A simple tutorial,"
 which is in section I of the PHP Manual.  Yes some manuals bury an
 introductory lesson like that way down after all the installation and
 configuration stuff, by PHP puts it right on top.  Did you spent 12 hours
 without finding the very first thing in the Manual?  Do you even have the
 Manual?
 
 Is your problem with MySQL?  If you have the data, can you enter it from the
 mysql prompt (creating the table if you need to)?  If you can't get the data
 into your database from a mysql client prompt, you have no hope of getting
 it in with PHP because you have to be able to write valid MySQL commands to
 use PHP to send those commands to MySQL.  Is the problem that you don't know
 MySQL?
 
 If you are past that, what is the problem?   Can you connect to the MySQL
 server?  Can you connect to your MySQL database or not?  Can you select a
 table?  Where is the problem? Which PHP mysql_* functions have you tried?
 The manual has detailed examples of most of them.  Look them up in the
 function index at the bottom of the manual.   In 12 hours you must have
 found a few of them.  What did you try?  What went wrong?
 
 > I know I must be missing something since I've been to the w3
 > site, codewalkers, phpfreaks,php.net(?), and many more.
 
 > If there is an easier way of doing this I would love to hear it.
 
 People get paid for doing this stuff.  Here are some hints if you hope
 to get paid for it --- or at least hope to avoid having to pay someone
 else to do it for you:
 
 1.  Use a text browser to get things to work.  Lynx is one, there are
 others.  Don't worry about making pretty-pretty until you have valid markup
 that works.  This is a heck of a lot easier, especially if you tend to get
 distracted by shiney objects in GUIs.
 
 2.  If you are stuck, divide the problem into little parts.  In your case,
 a way of dividing the parts would be a) make the form, b) get (actually
 probably POST --- thats a little joke) the form data to a handler, c)
 figure out how the handler will know the data is valid, d) connect to the
 database, e) insert the data, and (until you are certain you have it right,
 at least) f) figure out how to verify that what you did to the database was
 what you intended to do.
 
 3)  When you are stuck, try things out by hand.  Use PHP CLI to see if you
 are getting the markup you think you are getting and pipe it through a
 validator.  Use the MySQL command-line client (conveniently called mysql on
 many systems) to get your MySQL commands right --- because if you cannot
 talk intelligently to MySQL from mysql, there is no hope you can talk
 intelligently to MySQL through PHP.
 
 4)  When something works, save it --- save it some place you won't mess with
 it.  You can copy it and fill in the blanks to perform a task that is just a
 little different.  When you are copying something from your saved snippets
 for the third or fourth time, it time to consider making a function of it.
 
 5)  When you are read to make pretty-pretty, use stylesheets as much as
 possible.  If you use CSS, learn to use context so you don't have to have
 a class or id attribute on every little element.
 
 
 > If somene could point me in the right direction I could stop banging
 > my head and pulling my hair.
 
 > THANK YOU in advance for your advice.
 
 --
 Lars Eighner     <http://larseighner.com/>     <http://myspace.com/larseighner>
 Countdown: 583 days to go.
 An amazing thing about Christians:  people who doubt being related to monkeys,
 but are certain they belong to the same species as Paris Hilton or Karl Rove.
  Navigation: [Reply to this message] |