Connect, Insert and Explode

Yesterday, I found ADOdb, downloaded it, and uploaded it to my webserver, but I didn’t read up on it, or spend any time with it… so, today, after running a few errands, I retired to my home office to dig into the documentation, and see if I could get a database connection up and running, and if I could, then insert some data into rows in a table, and hopefully get my web app working.

Specifically, the user experience looks like this:

  1. Land on a landing page, or the home page of my site.
  2. Collect a little information on the landing page, and pass the user to a “more info is needed page”
  3. Collect more info on page 2 of the process.
  4. Insert all of the data collected on pages 1 and 2 into the database
  5. Send the user on to their “results page”

Granted, the above isn’t too complicated, but it’s also not something a) I’ve ever done before on my own (at most, I took other people’s code and hacked at it the last time I touched PHP) and b) someone that hasn’t looked at code in 8 years should probably attempt on their 3rd day of playing with code again, or so I thought.

Turns out… programming in PHP is kind of like riding a bicycle. Once you know the basics, even if you take some time off, once you get back on the bike, you can ride again pretty easily.

It took me about two hours to get the above process to work, but it works pretty well now.

On the first page, I collect the data for three fields, pass those as GET variables to the second page, were I collect another 21 fields. Then I pass the user to a “userhandler” page, that takes the data, processes it into the right formats, and then inserts it into the database, and the forwards the user on to the third page in the process, passing the two fields that are required to make the last page work.

I had to create the “get more info” page first.

After I had the HTML coded up, I added a bunch of PHP, so that it would grab all of the variables, and pass them to the “userhandler” page.

Then I created the database using PHPmyAdmin, which is the easy way to do it (as compared to actually reading up on all of the details on field types, etc… so my database isn’t nearly optimized, but I can go back and fix that later…

Then I had to create the “userhandler” page, and make it talk to the database, which took a little while, but was pretty straight forward, thanks to the documentation around “insert” and examples that comes along with ADOdb.

Once I figured all of that out, I got a little creative, and combined two fields on my “more info is needed” page, and figured out how to explode those two fields, so I can store them as distinct data in the database, but reduce the number of fields the user sees when they’re entering the data. Specifically, I wanted the user to be able to enter three or four words, but split them at the first space. Example #2 was exactly what I needed to see, to make it work.

There’s still a ton to do on this project, but I’m having a blast playing with it. Really gets the creative side of my brain engaged again.

0 Responses to “Connect, Insert and Explode”


  • No Comments

Leave a Reply