![]() |
I'm currently learning PHP which is my first programming/scripting language. I know html/css rather well and am grasping the concepts of PHP pretty well too. I have sort of hit a "plateau" of sorts though. This comes from a lack of understanding conceptualy not with syntax. You see, I'm a quite logical thinker but the concept of programming is elluding me. I know that it is just giving a dumb machine a bunch of commands but that's it.
I can't really put it fully in words but could someone maybe help me with the logic/concept behind programming? As it stands, I can follow simple programming rules but have no design concept. If I were asked to write, say, a user login script I would be totally lost. I just can't yet grasp building a script/program from the ground up. I know that this is an intergal part of being a good programmer so any help/ideas? Any suggestions on just great tips that helped you all in learning your first languages would be helpful too. thanks |
-shove-
Alright moving on. Basically when you are writing a program you have to decide what all the code will need to have in it to work.... For a login script: - Input to the PHP page (user and pass variables) - Connection to the databases with user and pass variables stored - Check to make sure that user exists - If he does then start a session in which identifies him as logged in... :
<?phpThe best programming practice exists in challenging yourself with the knowledge you have to create programs that are a little bit out of your reach, but not too much to where you cant accomplish it. |
-shove-
I'm not sure exactly what your getting at but I from what I get your having problems with thinking of program design and how to go about attacking a full fledged script. Pretty much like what tempest said I like to break down exactly what has to happen. Roughly at first, and then go inside each step and say EXACTLY what needs to happen for this step to work and to get you to the next step. Then once you have all your steps down you may very well, especially with a login script, need more than one file. So you look at each file and then begin to write out your steps, except in syntax and not words. I tried my best :P. Hope that helps you a bit. |
Having html and css background is good work. That's where I started, and then since then got a little inot C programming and vb programming (ok, I am not the best at those, but, know enough to do a few nifty tricks.).
As most of my focus has been in web development though, before I got into c and vb, I got onto Javascript. The basics of javascript itself has tought me a lot about programming, and how scripts are formed. Each language of course has it's own way of going about things, and it is in a way the same as English or any other language. Before I sit down to actually create a script I first figure out what exactly I want it to do. You can actually sit down and write it in story form wich will help you, for instance when the dog barks the neighbors wake up. When the dog doesn't bark, the neighbors do not wake up. In programming this sentence is usually stated differently though. It would read, If the dog barks the neighbors wake up, otherwise, the neighbors do not wake up. The problem is, that you actually have to define some of these words. In the english language everything has a deffinition. In programming, there are only some words that are defined, and the rest you have to actually define before you use them in your sentance. For my explination here, what we need to define is the dog barking and the neighbors waking up, as well as the neighbors not waking up. let us assume that we are getting the information from a form on a previous page, wich uses the post method (from an html form). So would be the script. :
<? Up until now this is a bit pointless, all that it does is print something based on wether or not the previous form posted "bark", but, this is the basic idea. Now you can do a bunch of different things based on the given information. you can define the database connection and path, and insert weather or not the neighbor is barking into a database, so on and so forth. I prefer to think of things in terms of nouns and verbs. For every action there must be something doing that action and all parts, if not defined under php's "dictionary" must be defined by using only words that are in php's dictionary. In the previous example, we defined dog, by saying $dog = $_POST['action']; This assumes that the name attribute of the form field on the previous page was "action". Now, if we had to create another deffinition for something, we can actually use the php dictionary and our own dictionary to define it. Anywhere were you would have to call the result of the form field "action" all you have to do is put $dog and you are good to go. I hope that this served to help your logical side, because I truely am the same way. If things don't make sense, or I can't translate them into logic english then they just don't go anywhere for me iether. Mike |
Hey, thanks guys for all of the help. It is really useful. Mike, your post was especially useful b/c it did help put it into logical english, which I now realize is what I need.
|
If you get a chance, pick up an O'Reilley book called "PHP Cookbook" it is an amazing cookbook that includes several approaches to the PHP login situation... it even shows you how to use HTAuthentication through PHP.
And it has many more receipes! And it is actually a fairly cheap book! |
I have it in ebook form.
|
Pizentios,
where can one find that ebook?...lol Nisim, Well, it confused me too for a long while, and then through the help of this amazing board and the help of my new found best friend..lol.. who is a programmer. I am constantly grabbing new information and ideas. I need to point him to this board though, but he doesn't have the patience for these boards. Regardless, I am glad that something I said finally helped someone on here...lol... Laters Mike |
| All times are GMT -5. The time now is 7:59 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC