A noob needs some quidance on php, mysql programming - php

I am working on a (dating, social) website. Basically, it's database system in which registered users can search, update their own data, send messages to each other, upload photos. I am a noob in web programming. I am writting the code (html, css, php, sql queries) line by line. It was okay when I had only 3-4 pages (registration, profile update, search, contact list), but now it's getting more complex (15-20 pages) and I find it hard to keep track of functions, variables, css ids and so on. Moreover I am asked to add more features (user blogs, forums) soon that will make it even more complicated...
I would like to get some guidance from professionals to speed up the development process. I have a half-ready system with my own database tables, php files, functions. And I have some experience in coding. I work with Eclipse, but I use it only as a text editor.
So, what's next? What development tools would you use to code such a system?
Thanks.

I have some general advice that I think will help someone starting out in any programming field
Find other people doing the same kind of thing and talk to them about how they do it. They don't all have to be experts as you can still learn from other beginners, but don't only talk to beginners or you will just learn bad habits :)
Use other people's code wherever you can. Frameworks, libraries, examples you found online. If it is a framework or library that lots of people use then go ahead and use it however you like. If its an example you found on a blog or something then make sure you really understand what it does because a lot of the stuff out there is rubbish!
Eclipse is fine as a text editor, as are many others. Changing text editor will not make your code better or easier to manage. Having development tools that you like using can make the whole process much more pleasant but it is not as important as you might guess from reading around the 'net. Spending two weeks learning a new coding environment doesn't help you get your project under control.
Try to make sure you pass as much of the Joel Test as possible, even in a team of one. You should be able to answer yes to at least questions 1, 4, 5, 6, 7 and 10.

OOP and i would advice to take a look at other open source social websites/engines to see if,
1) migration possible (since yours is half-ready, according to you)
2) reuse their framework/ underlying models possible.
and since you will add more features to your existing one, i recommend you to take a look at below:
FYI
[1] Social Engine.Net http://www.socialengine.net/
[2] Social Network Engine Comparison (by Wiki)
As for coding IDE / development tools/techniques, you will increase your productivity if your environment is php integrated(on the fly function/method lookup).

I would strongly suggest using a PHP framework like Zend, Symphony etc. than simply writing PHP files. It will help you use something called an ORM for database queries which helps you port from different database servers like Oracle, MySQL etc. Apart from that, your question needs a very detailed answer. Try looking up some of the software development practices and tools that assist in them (e.g. trac, svn etc.) I have found these to help me be organized and stick to a schedule.
And how many users are you looking to serve ? Think about the scalability of your design.

Related

What to do after learning basic PHP? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have learned extremely basic PHP (I think so) using Lynda Tutorial. After that, I feel, I got some grip on that language. My ambition is to become a web developer! After some googling, I planned to learn some more advanced and practical php by using websites like PHPSCripts, Webapps etc..
But, now I'm in a confusion! After my studies, when I seek for a web developer position & got selected, how will I work, by just knowing some language basics?
Can you guys help me to become a good web developer, what will I have to learn & how to learn?
Also, can I get the steps to do a practical PHP project.
As a web developer it is important to have client and server side skills. But there are few web developers which are excellent at both... But knowing the basics and where to look for info is definitely a good starting point.
I would recommend to work through the following list(s) in the order presented. If you feel comfortable with a topic, move one. Even though that in reality you will often have to go back and forth during the learning process...
Client Side
HTML / XHTML
CSS
a JavaScript Library (e.g. jQuery, prototype/scriptaculos, etc.)
Server Side - Infrastructure
familiarize yourself with shell scripting if working on Linux (e.g. bash, etc.)
Webserver (e.g. Apache)
PHP Server
Databases (e.g. MySQL, PosgreSQL, etc.)
Server Side - Programming
PHP
SQL
Advanced Topics
After getting familiar with the basics...
AJAX (this is placed here because it is a client/server topic, not because it is advanced...)
Object Oriented Programming (OOP)
Security issues
Source Control Management (SCM) -> (e.g. git, etc.)
Model View Controller (MVC) software architecture
PHP Frameworks (Zend Framework, Symphony, CakePHP, Agavi)
Unit Testing (e.g. PHPUnit)
Object Relational Mapper (ORM) for PHP (doctrine, Propel)
Usually this keeps you busy for a while. At least it kept and still keeps me busy... ;)
Here are few suggestions:
Read these advanced/practical php articles on phpro.org
Learn the basics of OOP
Familiarize yourself with php frameworks and CMS
Familiarize yourself with HTML/CSS/Javascript
Try to make clones of other websites
Try to volunteer in open source projects, you may get started at:
openhatch
sourceforge
Im my opinion, A good webdeveloper MUST know:
HTML
CSS
JavaScript
After this, it's important to know:
Jquery
XHTML
Crossbrowsing (diferences of IE X Firefox x Chrome, etc)
Rationale:
HTML: it's the base of web.
CSS: in 2010, it's the base of web.
JavaScript: only the basic, to understand jquery after.
Jquery: you can solve a lot of problems quickly and it's large used.
XHTML: because your page may broke in modern browsers, if has a <br>, not a <br/>
Crossbrowsing: there is more than one browser in the world.
Just keep on practising. You will likely need solid HTML / CSS skills as well as PHP since the two go hand-in-hand - it's also useful to learn MySQL. Spend lots of time going through the tutorials on the excellent tizag.com as well as Lynda.
Once you're comfortable with all that and you're ready to move onto something more advanced, it's worth looking into Wordpress customisations and plugin development - that has the advantage of being pretty easy to use, with an awesome support community, and a whole bunch of mature code that you can look through yourself to get more familiar with how the language is used in the real world.
After that, try a framework like CodeIgniter or CakePHP - these are awesome for your productivity but do make sure you're comfortable with the basics first as the learning curve can be pretty steep and you want to reduce frustration as much as you can. :-) Learning design patterns will also be helpful at this stage.
One thing that will always be important to you, your users, your applications, and your potential employers is code security. I can't stress this enough. As soon as you put an application into real-world use, you have a moral and professional obligation to make that application secure. http://www.addedbytes.com/writing-secure-php/ <- read, digest, read other guides. Security is the single most important thing that a PHP developer can learn.
Above all, have fun! The best developers tend to be the ones that get genuine enjoyment out of what they're doing. You might find yourself eventually leaning in a different direction and using completely different technologies, so always keep your eyes open and be prepared to learn new things even if they don't necessarily 'fit' your current skillset. Also the more general knowledge you have about programming patterns, the better you will become in individual languages. Remember that it's an organic process so you will need to let it develop naturally - but help it along by exposing yourself to as much as possible (foreign language teachers call this 'immersion' :-) )
Regarding PHP
Make a small project using PHP, so you know that you know.
Learn a (MVC) framework like CakePHP or Agavi.
Read this SO answer.
Regarding Web Development in General
Know about CSS, XML, XHTML, XSLT, W3C validation, HTML5, JavaScript, AJAX (and most other acronyms you come across).
You will find there are various libraries which make your life easy, use them. And there will be one browser that will make your life difficult, but you will have do deal with it.
A solid web developer needs an understanding of HTML, CSS, JavaScript, and the server-side scripting language of her choice. But still more important is a solid foundation in programming. You don't have to be an expert computer scientist, but you need to understand how to structure a program and how to solve problems in a sensible way.
Most professional web development involves database access of some sort. Teach yourself SQL, and use a real SQL -- not Access -- for the effort. You can run MySQL or Postgres on a laptop these days, and it's free.
Learn to design databases well. Learn about normal forms, and indexes, and so forth. The time you spend on that will pay off in spades.
Take a while to study up on security. Look at the security bugs that have afflicted high-profile projects and sites. (Hint: they're pretty much mostly about trusting untrustworthy data, or else relying on old out-of-date infrastructure, but the consequences include site defacement and the compromise of valuable information.)
And then, take on a charity project somewhere. You won't get turned down, and you'll cut your teeth, so to speak. Just make sure you're not storing social security numbers or something crazy like that, because charity workers are often vulnerable to social engineering attacks.
the very very first thig to do is to learn Object Orientated Programming (if you haven't).. then you might want to start learning the MVC pattern... and then you must decide either you star using frameworks (like cakePHP, Symphony,Zend) or you prefer using CMS (like joomla or wordpress)... on the process you might also want to learn javascript using a framework (mootools, jquery or prototype)...
Edited: i forgot about databases and sql!! wow.. there's a lot to learn!
The only way to become a good programmer on a certain platform, is to study something more than just tutorials. Read a book, at least. Then the rest comes with practice.
A good way is to also learn a specific platform (depending on what they work with). Some work with Wordpress, so once you know basic PHP and how to use it with databases, and how to work with databases, you would be able to quickly make some basic information websites. Others use Joomla, Drupal, DLE, to quickly build websites, without having to hurt their heads with full backend and frontend architecture. If you need a more general approach, to be able to make more specific web applications, use frameworks like Zend, CakePHP, Symfony, CodeIgniter.
Also, besides knowledge of PHP, to build a small website by yourself, you will also need to know HTML, JavaScript (with AJAX, possibly a framework like jQuery), SQL.
And last but not least, you will need to learn how to protect the site against XSS, SQL Injection and other security threats.
Learn Object Orientated Programming (OOP for short).
Watching any programming tutorial is different than watching any movie. You need to have practice and have experiments form different angle of codes. Prentice and research is only way to get into the deep of any language. If you think you have well understanding about php then try to make some small application like phonebook which have database connection. After that you can move for any frame work like laravel, cakephp. But I always recommend to do at least one small project with raw php before move for any framework because when you come from raw php you will start loving working with frameworks otherwise you will may feel boring to learn again something new as my point of view.

Getting back into the website development game [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
Back in the 90's I used to develop websites using Cold Fusion. We also still used tables for most of our page layout, hehe.
I just started getting back into website development again seriously. I'm getting a pretty good handle on the basics with CSS and starting to add Javascript. I'm guessing that I will eventually add PHP as a modern replacement to my CF skills.
Right now I am using an old copy of Cold Fusion studio for my editor and of course Photoshop for my graphics. I have also discovered Firebug and found it to be very helpful.
I was wondering if the community here could give me some pointers as I start back out in this field. Do you have any software suggestions? A new editor I should use? Other debugging tools? Languages you would recommend?
Any comments or ideas that would help a website developer who is starting out would be greatly appreciated. Thanx!
You might consider Eclipse for your IDE. It's free, open source and pretty full-featured. Also, you'll want to implement source control. I like Subversion, which integrates nicely with Eclipse.
If you're looking to update your image editor and you don't want to spring for Photoshop's licensing fee, GIMP is very much improved, open-source and free.
You may want to investigate the various CMSs and frameworks out there. It's possible that one or another may suit your target market. And they can speed up development significantly once you learn their quirks.
Also: JQuery. Don't spend your javascript coding time dealing with cross-browser issues and common tropes.
I would look at Net Tuts+, Think Vitamin, and Smashing Magazine to get back up to speed on what's fresh.
You definitely want to look into a framework. You'll be disappointed with PHP out of the box if coming from ColdFusion, it's not nearly as friendly. This is assuming you're going to use it for database applications, otherwise it really doesn't matter.
Of course, I'm obligated to tell you to check out Ruby on Rails.
I'm a big fan of jQuery for elegant, client side cross-browser javascript.
If you want to look at some "modern" concepts on the server side, REST is getting some airplay, and cloud stuff like Google App Engine can make for a really efficient development path (scalability 'for free').
But I still stick with the old-school IDE - syntax highlighting text editor. Or eclipse, which sometimes isn't much better ;)
I agree with finding a framework. As a general editor, I can't live without notepad++ - http://notepad-plus-plus.org/
It is a text editor, but it does so much. It has code highlighting for many languages - it is an indispensable tool for me.
For CSS I would recommend reading CSS Mastery for a nice overview including browser differences / bugs.
As far as the software is concerned, I still use Dreamweaver for my old, template based sites, but I´m moving to NetBeans for my new sites. Apart from all the expected features, NetBeans has nice ftp integration, one of the reasons I started using Dreamweaver years ago.
The Opera Web Standards Curriculum is a great (re)start for writing correct HTML and CSS and JS. Read it at your own rythm (I mean pace, sorry for my english).
IE6:
Just give up with IE6 if you can (if your clients don't ask specifically for its support). It'll give you plenty of time to learn better things.
If you work for administrations or companies that work for them, that won't be the case; prepare for severe headaches.
Position is everything is a great resource. Don't try to understand everything but at least learn to know and recognize those IE6 bugs. A doubled margin, 3px margin, content seen twice, disappearing content are very well known and documented bugs but if you don't know here they come from ...
Conditional comments and hasLayout (zoom: 1; in one instruction) have been better explained elsewhere I believe, because P.I.E. is really an old site (though still useful).
Page layout:
If you have used tables, spacer.gif and are new to web standards like CSS 2.1 used the right way, you'll have a hard time for layouts displaying correctly cross-browser even if you know hot to style entire blocks in the page.
Don't bother to reinvent the wheel, use resources like HTML Gala. Pick up the layout you need depending on fluid/fixed width, number of columns and whether their width is fixed or not and whether there is a footer or not, then understand how/why they did it but don't try to do it from scratch: it's just too complicated when you start to use CSS.
Tools:
a good text editor
Firefox and great extensions
and you're done. Quite :)
Chrome also has extensions, keep an eye on it in a few months. For now nearly everything needed by a webdesigner/webdeveloper exists on Firefox and some of them on other browsers too.
Firebug that you already cited. Explore its tabs, its select boxes and breadcrumbs, where you can edit things live, etc. And I heard you like extensions so dev created extensions for this extension (meme ©Xzibit :)), check for extensions to Firebug. I use Pixelperfect and CSS Usage mainly but others are useful too.
Web Developer Toolbar is the other must have extension. Be sure to try every option at least once, there's even a gem in the last menu, first option that only a few know.
QuickJava allows quick enable and disable of Java, Javascript, Flash, Silverlight and Images from the Statusbar without having to open any dialogs.
MeasureIt to measure width and height of an element or margins.
ColorZilla brings a color picker (Shift-Esc)
Fireshot for snapshots and commenting them, useful if you want to communicate with a client or a designer, write documentation or for your portfolio.
Others
source control (let's avoid the pain of "It worked 3 days ago/I just deleted the wrong file aaargh")
two offline backups that won't get robbed/flooded/burnt with the rest of your house/office. The second one can be an USB key/HD with Truecrypt given to family or friends, along with a password only known from your wife/husband and your parents or children for example. You can keep the first one with you (encrypted is better if you get robbed).
CMS: you can test Drupal, Joomla and Wordpress as a beginning. Magento for e-commerce. Numerous plugins for each one but their quality may vary!
I'd look at Net Beans as an editor/IDE if you definitely want to go the PHP route.
I'm a .NET developer, so maybe i'm biased but i'd look into the .NET framework, and specifically ASP.Net MVC (go for c# if you can in my opinion)
It all depends on what you want to do in the longer term, and if you want to do this just as a hobby or to work as a full time developer.
In the area of the UK i'm in it's a bit harder to find PHP jobs in the larger companies, many are tied in with Microsoft and rely on their technologies such as .NET and MS SQL etc.
Are you looking at taking on more of a design role, css/xhtml coding, or writing applications, web services etc?
Note, just to clarify I also use PHP for many projects outside of full time employment, you can make a living using most technologies, so go with the ones you prefer.
Also check out Tizag for loads of useful, easy to follow tutorials that can quickly get you up to speed on the basics.
Whichever route you go down, definitely get familiar with the jQuery javascript library, it's very powerful and many of the basic functions it makes available are expected in websites these days by clients i've found lately.
I've not looked at it myself yet, but the new PhpStorm IDE seems to be getting a lot of praise at the moment
Futher to the nettuts+ answer.
If you're on a mac, i can highly recommend panic's coda http://www.panic.com/coda. It makes writing css a breeze, even though i hand write mine. However if you're strapped for cash a free alternative to that is textmate http://macromates.com/
Firebug is a fantastic little tool, and there is also web developer toolbar https://addons.mozilla.org/en-US/firefox/addon/60/, which is also very very helpful! It has built in links for validating your html and css with w3c.
Languages, definitely PHP imo. I started out in ASP.NET, found it good but i just feel more comfortable in PHP, my suggestion for you is to try them all out and see what works best.
Also when you feel comfortable, take a look into the kohanaphp framework (kohanaphp.com/), its a fantasticly simple framework which as someone else put it, is unobtrusive, you can use as much or as little of it as you like.
Finally my best advice is to just spend every waking moment trying out new things, like making a html page and styling it, making a contact form that kinda thing, i found just messing around is the best way to learn a language.
Hope this helps you get started :)
ColdFusion has evolved nicely since the 90's, check out the details of version 9 before abandoning it. Also, consider CFBuilder for a nice IDE for ColdFusion.
ColdFusion 9
CFBuilder
here are some helpfull links.
css-tricks.com
net.tutsplus.com
ajaxian.com
webmonkey.com/category/javascript
smashingmagazine.com
(i visit them daily to be up to date with web Design / development).
I think there are two things that mark modern web development:
Web development frameworks
JS libraries, mainly jQuery
Although most of the concepts behind today's Web development is not new (MVC structure, AJAX...), re-discovering these led to a shift in how we do things, and brought back the trust of veteran developers in it as an effective and serious medium.
I definitely recommend that you dive into Ruby on Rails. Learn the main principals and concepts underlying the framework: reusable modules, elegant MVC structure, templating, RJS...
(Alternatively, you might like to check cakephp, the PHP cousin of Rails, which inherits most of the family traits)
Eventually, when you play enough time with it, come to like it and understand it well, you'll stumble upon other frameworks that might suit you more (for one reason or another). My experience moving from Rails to Django (Python), then to Google AppEngine (Python or Java) was nice and rewarding (in personal satisfaction, that is).
That's for the back-end.
Then you come to the vast world of ninja-style-ultra-useful-and-still-fun jQuery (and its numerous plugins) where the joys of web development continues.
Enjoy the ride!

What language to use - simple form + MySQL + admin page

Apologies if this is not the right place to ask but here goes...
What should I use to create a simple web application for our website?
I'm the IT guy for a small non-profit. On our website we have a page with a large form in which users can fill out information on an application form. The information gets sent to a MySQL db. This data can then be accessed and edited by a couple of members of staff behind a logged-in part of the website. There's only two dbs being used: the main one with all the data and the one used for login details for the web app. It's all done with PHP and functionally is fairly simple - just a form with lots of fields to collect data and a basic secure "manager" page to do a bit of stuff with that data.
The problem is that we need to make changes to the app, and to extend its functionality quite a lot. I have a little bit of experience playing around with PHP but I've taken one look at the code used and decided it'll take too long to decipher it and see what's happening where. The code is uncommented and a bit of a mess.
I'm starting to think that rather than investing time to relearn what little I knew about PHP and untangle all the code, I might invest the time in learning another language and/or framework to get this done. I want the resulting web app to be a lot easier to maintain in future by me or anyone else who comes along and has to make a change.
Would you recommend using Django/Python for a project like this? Zend/PHP? Just PHP and notepad? I want the app to be done fairly quickly so the less steep the learning curve the better. Many thanks for you time.
Another good PHP framework is CodeIgniter.
They also have a good webcast that outlines how to begin with the framework as well as create a simple blog [tutorial].
I would recommend a PHP framework, such as CakePHP. Spend 20 minutes of your time and follow their blog tutorial.
Using PHP alone can be tricky, especially when you will have to deal with security issues.
From what I can see you have asked 2 questions.
1. Should you maintain and extend the current code base or do a rewrite?
Rewrites always take longer than you think. And even if you do the rewrite to avoid learning the codebase you would still need to learn the current codebase to ensure you capture the current functionality before adding any new features in the rewritten codebase.
I would keep the current codebase and maybe do some refactoring as you add features.
What should language and frameworks should you use?
I would stick with PHP, CakePHP is a solid framework and so is Zend. I would read up on both and do a couple of tutorials and make your decision.
As Anax states, I'd suggest that you look to use PHP. If code is already implemented then you have a start.
PHP isn't hard to re/learn. I know some don't like it, others like it but simple fact, either way it isn't hard to learn. But, more importantly consider the following:
You obviously have access to the hardware stack required to use PHP and MySQL. Introducing a new language/technology may cause unforeseen issues with getting a production site set up.
Now this doesn't mean that you can't write certain components in other languages. You could, if you were so inclined. But you probably shouldn't be so fast to get rid of PHP just to learn another language. Do you have important (technical) compelling reasons to use something other than PHP?
If you are mostly concerned about the spaghetti code in place, you can get that anywhere -- even new development. Better to re-factor the code and fix and add to what you have than start from scratch.
I can offer some general considerations:
Whatever language you choose, get a good IDE for it. Having automatic syntax validation and code completion helps a lot if you're a beginner. Don't use plain text editors.
Teaching yourself how to code well will make for a very frustrating experience unless you have a lot of patience. This generally comes from being really sure that you want to do it.
Be very conservative in your time estimates. Having many setbacks is guaranteed if you're a beginner.
Start out by focusing on reading about writing code, not focusing on writing code. If you're learning Python, read the official tutorial first. The same goes for PHP.

PHP Practices for first time web-programmer [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have this idea for a website that's been floating around my head for quite sometime now and now have finally decided to get to work on it. Due to the nature of the project and my experience I am getting comfortable with the idea of running it as a PHP+MySQL application on an Apache server.
This is my first time doing web programming of any sort(I have a background in sysadmin and mainframe systems coding) and I am pretty unsure of what practices to take into consideration so that I don't find myself undoing/redoing things later in the project. Considering all the flak the language has taken on StackOverflow(which can be seen here and here) it would be nice to have a set of common mistakes to watch out for for a beginner like me. I did find this thread outlining things to avoid in PHP but most of the points made little sense to someone like me who's just setting out in PHP.
Do you have any suggestions, tips or tutorials outlining common gotcha's in the language which might come back later in the project demanding entire rewrites.
For what it's worth I am currently working my way through Programming PHP(O'Reilly) and PHP in Action(Manning).
I was in a very similar position a couple years ago, having come from a NOS background myself.
I actually started with PHP and MySQL for dummies. Once I had absorbed the knowledge contained therein, I hit the Web (I used SitePoint a lot, like Boushley recommended) and I read a couple of O'Reilley's book on the subject.
Once thing I will tell you, is that if you want to streamline your understanding and your efficiency, I have found great success with a number of MVC frameworks(CodeIgnitor, CakePHP, etc). If you have no idea what MVC is, I recommend finding out. Now that I use MVC, my code is easier to understand, modify, troubleshoot, etc.
And honestly, half of the learning in PHP is running into those common mistakes and learning from them. Its hard to appreciate those 'common mistakes' until you make them.
Don't worry about HOW you are going to learn, just START leaning!
If I could give you one piece of advice, it'd be to use a framework - they will make your life so much easier. They take away all the repetitive code from programming websites, handle security concerns and abstract lots of things, as well as make you build your website using a pattern such as Model-View-Controller.
I highly recommend the CodeIgniter framework for it's simplicity, power, great documentation and ease of use, but there are plenty of other good frameworks too. There are lots of questions on SO on this so have a quick search. There is a fantastic introductory screencast on CodeIgniter (soon to be a series) from BinaryCake, so check that out here.
I hope that's helped! If you have any PHP concerns, feel free to message me - it's my area of expertise (along with CodeIgniter) and I love it!
While still developing, have all errors show up:
ini_set('display_errors', '1');
error_reporting(E_ALL | E_STRICT);
Can save a lot of time (in case of say, typos in variable names). Change this when it goes live to not display or only display "real" errors depending on the type of site and security levels involved (you don't want everyone to know paths and variable names and such..).
Find a variable/function naming convention (under_scores vs camelCase vs..) that suits you and stick to it. Also, classes go in the /class directory, includes in /inc etc. Both these make it easier to understand your own code years from now. Oh, and the same goes for coding style, I guess: choose one and stick to it (indentation, bracket style, ..).
Comment your code :-) Personally I also have a little log at the end of longer files that shows when I did what and why. Each addition is timestamped, and the same timestamp is also in the comments behind the change itself, as the line number on which it sits can easily change. Similarly, in an included file containing a bunch of functions, I have the list of function names in a comment at the top of the file, with a one-line description behind them.
Finally on security (though this should really be your first concern ;-) ), treat all user input as suspect. That's POST & GET data, cookies, user-agent string, search strings - anything that is supplied by the browser. It's trivial to change cookie data or change/add form items.
Read up on SQL injection & XSS attacks, and look at PHP's relatively new data filter functions: http://php.net/manual/en/intro.filter.php
Google any of these to get some good reading
Don't use register_globals
Turn off magic_quotes - escape all user entered input in SQL statements
Escape any user entered input printed with htmlspecialchars()
Plus a lot more... These are some common things to watch out for though.
There are a number of great websites out there with lots of tutorials. One that comes to mind is Site Point. They'll try their best to sell you a book or two while your're there, but they do have some decent articles. This article for instance discusses some common security blunders in php.
http://www.sitepoint.com/article/php-security-blunders/
They have lots of them...
http://www.sitepoint.com/search/search.php?ps=10&q=php&submit=Search
Also a nettuts.com has a load of tutorials an things of that nature. They're more all across the board though.
http://nettuts.com/
And I think pretty much everywhere you look you'll see the common ones like watch out for register_globals, magic_quotes...
one good book to look at that is also free to download here covers beginner to advanced PHP techniques and is good way to learn good standards :)
Use a framework and use Object Oriented Programming
Books are great for learning additional languages, but for your first one, a good video tutorial is a great way to go!
Register for a Lynda.com account (google: lynda trial) and sign up for as many one day trials as you need (or be a good honest person and purchase a week). They have a pretty good beginner and advanced PHP series of video tutorials which are (IMHO) a great way to learn your first language.
A tip: If you can start programming Object Orientedly from the get-go, you will save some time in the future and learn good practice from the start, luckily the advanced tutorials cover this!
Here's a link: http://www.lynda.com/home/DisplayCourse.aspx?lpk2=435
I've never taken this particular course (when I learned a few years ago, it was different), but I just recommended this to a friend (who was just starting), and he really liked it!
Hope this helps!
If you're new to programming in general, A database backed web application is likely to be a bumpy ride. You will probably be programming in at least two, real programming languages, PHP and SQL, and if you're going to do anything of modest complexity, JavaScript too. Keeping them strait will be rough, because they are all quite different.
Just to warm up to programming, you might want to start instead using a more focused learning excercies, such as working through the Euler Project problems, or Code Kata.
Either way, Try to pick up good habits wherever you learn about them, including the popular suggestion here of using an MVC framework for the heavy lifting.

Help For The Copy & Paste Generation Of Coders [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I myself am one of these types of coders, who never learned coding in a formal setting, but am instead, self-taught by the use of copy and paste scripts, and pre-authored works available through GPL projects and premium software's(which is often the way commerical script companies show you how to change, or update code in their script ie. "Copy & paste this on line 234, etc..")... this are my beginnings.
I don't understand how what I do works, but I am getting good at what I do with code, though I feel because of my informal learning methods, that I lack in knowledge, some of the really simple, but necessary principles of web coding in general(the ins and outs of servers, browsers, etc). I feel as though I have started from the inside of understanding code, the practical side.. and lack the basic fundamentals, and theorized understanding of what I am doing.
I also know quite a few others who are the same, who started learning in the same communities as I, and are pretty much at the same point as me... Feeling as though something big is missing from the picture.
I see the lacking in my discipline when I attempt to use PHP authoring tools, which I find very challenging to understand... and this is becoming a downfall on the time frames in which I complete my projects(having to hand code everything). I also find it difficult to ask for help at times, for lack of the specific language that comes with programming, and being able to use the right words to explain the intricacy of my problem.
I was a hairdresser by trade, I worked as a bartender, and hotel manager, I'm a business consultant by profession. I've been learning web development slowly now for 3 years, and I have taken on quite a few commercial projects over the past 2 years, but I'm obviously feeling some lacking in my skills & overall knowledge.
Basically, Id like to ask any experienced coders who've had similar beginnings to give me an idea on how I can adapt my coding disciplines to be more effective and productive. What would someone with such an informal understanding of programming want to seek to learn, and understand. What are the things I must know as a programmer... and what is a basic overview of the whole picture???? Feel free to direct me to articles
Any help is always appreciated.
Lea
Edit: Just to give a round up of my actual capabilities. I am a programmer, I do author my own code from scratch.. and sell my work. I can write PHP functions, and classes, use mysql, have a good working understanding of html & css, and am very good in the design aspects(web graphics), and am learning javascript/ajax/jquery, as I am using jquery in most of my projects. Thanks for all of the answers so far!
Realise that "copy and paste programming" is not actually programming, despite the name. The act of "programming" is figuring out how something should work, and what code is needed to make that work. Therefore, when you copy and paste some code, it is someone else who did the programming. This isn't a bad thing necessarily, as you shouldn't always need to write code yourself. But to call yourself a programmer, you do need to have written the code yourself.
You will want to start humble. Don't try to write a large complex application as your first step into programming. There is a good reason why most people who are taught programming are first taught how to print "Hello, world". This is because there is a lot more that you will need to know than just what code to use - you need to know where code execution starts and how it flows, and that sort of thing. You need to be able to look at the code and step through it mentally, knowing where program execution will go next, so you understand how it will work.
Take a tutorial or course in programming. There is so much free stuff online. Do not trust any tutorial that just gives you large chunks of code, make sure it forces you to actually come up with some code yourself. Do exercises such as sorting strings, calculating fibonacci sequences, and the like, and "echo" or "print" the results. Learn about conditional statements (like "if") and the "for" loop and play with these to do various things.
GUI or forms programming is more complicated; make sure you know the fundamentals of the language before you go looking through any API or framework documentation to see what the language can do. You'll need to know how execution flows, how to write functions, what types of variables you can use etc before you can effectively use an API or framework anyway. It is boring not being able to do cool graphics or forms and sticking to basic text or number processing, but you have to walk before running. Make sure you are doing, not just reading. When you learn about something new like the Array type, the "while" statement, try it out. By actually doing it, you'll "get it" a lot faster than just reading a book or website and you may be more likely to remember it.
Read books about programming. Some people say you should learn C before you learn anything else. I don't necessarily agree, but if you do learn C then the book to read is "The C Programming Language" by Kernighan and Ritchie. Many programming books are very interesting but either not suitable for beginners, or aren't going to teach you how to actually begin programming. This one is an exception.
Use a decent text editor with syntax highlighting and line numbering. That's all you should need. A big IDE that also does code completion and the like is not necessarily helpful at the learning stage. Don't spend too long choosing one or setting it up. If you don't already have one, just get Notepad++ (if you're on Windows) and be done with it. If you don't like it you can change it once you get more proficient. Or if you've already paid for Microsoft Visual Studio then use that, but don't go out and get it just for the sake of learning a language. Avoid falling into the trap of spending all your time sharpening your tools and no time using them.
The easiest and fastest way to do this? Find a mentor, or a set of mentors. Not necessarily a real-life mentor, they can be offline, although a real-life mentor is more practical.
You can find these people when you participate in local software development communities, e.g., forums, or user group meetings. Frequent these places, both offline and online; the amount of knowledge that you will learn is immense, not to mention the benefit of being able to bounce ideas off of other people.
Code Complete and Pragmatic Programmer are likewise excellent book suggestions above. I suggest you go with Code Complete first, as it tackles on how to make your code sensible and elegant, which you certainly can use immediately.
Goodluck!
We all learn differently, so don't feel handicapped because of the way you've entered the field.
I guess the simplest, easiest thing I can suggest would be to get yourself a PHP book (seeing as that's what you're familiar with right now) and start from there to build up confidence.
In your spare time, just create some very small basic apps to practice without any pressure. Then take on a language like Python, Java or .NET.. depending on what takes your fancy. With a language or two under your belt, then you can take on books like Code Complete, which will cover some of the more esoteric areas of software development.
Good luck, this is a profession where you really never stop learning.
in case you're interested to becoming a better programmer, i must recommend that you read the pragmatic programmer, don't worry, it's not a full text of codes which will make you pull your hair out but useful lessons which can only be distilled from years of programming experience written in an easy to read but still very informative kind of way :)
I'm not at all convinced that the premise of the "Copy & Paste Generation" is any kind of new phenomenon. Only the tools are available to a wider audience now than before.
If you want to really hone your skills, it might be worthwhile to take some classes, either at a local community college or in a self-directed learning environment through the use of some of the many, fine online resources or books
I believe Code Complete is another book along the same lines of the Pragmatic Programmer that has already been recommended.
I have been your situation before, senior year of high school in an internship I "learned" c and shell programming mostly via copy and paste, and later on at various times when I may have been in a similar situation with specific technologies.
My recommendations:
Take a class at your CC. The one you want is the one that is the prerequisite for the advanced programming classes. They probably also offer a "I've never touched a computer before" level class but this one won't be the formal prereq for the follow on classes. This will probably be in Java.
Work your way through one of the better programming books that includes exercises. Kernighan and Ritchie's C Programming Language is a classic. This would be my recommendation because C is similar enough to PHP to be familiar, but different enough that you will be able to keep them separate. I say this even though you will probably never write a single line of production C. Paul Graham's ANSI Common Lisp is also a suitable choice.
If you are really hard core and have the dedication, you can try Structure and Interpretation of Computer Programs, by Abelson and Sussman. This is the book used in the first programming course at UC Berkeley ( http://webcast.berkeley.edu/course_details.php?seriesid=1906978389 ) and at MIT ( http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-001Spring-2005/CourseHome/ ). This may be too difficult to attempt outside a school environment. It's designed for bright young students with nothing to do but study and with the regular opportunity to get tutoring from grad students. I include it only for completeness.
I would avoid any web programming books. You already know web programming. I get the impression that you are feeling like you are hitting a bit of a wall, and looking at a way around or over that wall, rather than trying to go directly through it.
I would advise against looking into any web oriented book because it will not give you the big picture, it will describe technique only as they apply to web programming. The important things to understand are how a computer actually operates, the difference between the stack and the heap, pointers, the basics of garbage collection, recursion, and it'd probably be helpful to understand at least extension mechanism. I mean, if you understand shared libraries on Unix, or DLLs on Windows, or classpath and jars on Java, or how to create a library in PHP, Ruby, Perl or Python, any one of those will be fine. It's just the concept of loading outside code that's important.
Take a look at The Structure and Interpretation of Computer Programs and see if you think it would help.
Copy and paste programming refers to using the same code several places instead of putting it in a function or class. If all you do is modify existing source code while following a howto guide, what you do is not called programming, just copy and paste.
What you need to do is read a book on programming, whatever you feel your level is. If you feel its copy and paste level, you should start with a beginners book. Forget everything you think you know, read and follow the book. When you've finished you can remember some of the clever code(?) you noticed during your C&P days.
Mastering any skill takes time, but if you keep at it you'll become better. There is nothing inherently different about programming in that sense. Exactly how you learn best, is a highly individual matter, so it's really hard to give any meaningful advice on that. In my experience, combining different types of learning (practical experience, being around other programmers, reading books, formal education etc. etc.) in even-sized doses works better than just pursuing one type of learning (Such as formal education).
You might find these readings interesting, if you don't know them already:
http://www.norvig.com/21-days.html
http://softwarecraftsmanship.oreilly.com/wiki

Categories