A tree too big to embrace grows from a slender shoot. A thousand mile journey begins with a single step. People commonly ruin their work when they are near success. Proceed at the end as at the beginning and your work won't be ruined. -- Lao-TzuI find this particularly relevant to programming projects. Don' panic or take shortcuts at the end!
This refers you to my website, and the course page thereof,
Recorded last August, only change is that course meetings both start at 11 AM, for 1 1/2
hours - which we never exceeded last term.
We covered 4 languages during CS203, this term we add SQL, the database language,. The goal is to allow flexibility in storing and retrieving data.
Databases store tables of rows and columns, which represent entities (such as students) and relationships, such as who is enrolled in which courses. Your database can be accessed by any PHP script.
A look at php fuctions for executing SQL queries on a database. I store some data from a form (poems) into a table, instead of writing it to a log file. This is more flexible than writing to a log file. Later I can then display results selectively, and control how they are formatted.
After that, I show typing sql commands in a terminal window, and create a table, named foo. You can get to this on linux by typing
psql jensen
About the course, about databases and sql. Includes a demo of doing sql commands in a terminal window.
As promised, I develop an application with a form for choosing colours, and a PHP page tht receives the form data and stores it in a database. Thrills and chills! After an hour, there was still a problem. Moral: Quit, have supper, and after, the problem is quickly solved. Know when to stop!
During this meeting, I was asked about using pg_query for showing what's in a database. It went badly, so I promised to record a video to finish.
Here is the promised video of the choosing colours example. You can see the result at osiris colour.html. It is important to see pg_errors, and remember how your database tables are oganized!
In particular, it is your choice what you want to do in the course, be creative. I want you to know about SQL, you can now use it as much or little as you like. I call attention to problems of robots exploting your site, and the abuse() function I created for your use. I was asked about storing passwords, as a hash, so they can't be stolen, and I made the next video about that...
One wants to store not passwords, but a hash that does not reveal the password. I show the code involved, and also when you view the tryme.php page, You will see a pattern for requiring a decently hard to guess password.
Turkeys were outside my window. Summary of this week's discussion of fighting abuse, and avoiding SQL injection.
The functions count(), min(), max(), sum() and avg() can be usd in SELECT statements, which then give one row. In conjunction with GROUP BY, a groupings are formed, and the functions applied to each group. The SELECT can only have the group attribute and the functions.
Mostly a discussion about IFRAME, and a question was asked about update information when a form is on the same page. This proved tricky, and I finally solved it a day later. I realized that submitting the form would take you to a php page, that page can update the data to be shown, and then use a meta tag to bring the user back to a new version of the original page. I have done so with the Poetry page.
I will try to describe there how it's done.
About Labs 8,9,10 and finishing the course. I am asking what you want to do with your pages afterwards. If you keep your site, keep it updated and protect against abuse and SQL injection.