What script should I attempt first? - php

I've just got started with the basics (as well as a few intermediate aspects) of HTML, CSS and PHP. What is a good starting point to practice these 3 languages?
I was thinking of writing a URL shortening script but I was wondering if anyone here might have a better idea.
I am looking to develop something that would help me broaden my knowledge of the above 3 languages, but it shouldn't be too advanced that I wouldn't even know how to start it.
Any suggestions would be appreciated.

Whatever you write, if you allow users to input anything, prepared for it to get spammed and hacked mercilessly as soon as it goes live.
Therefore I'd suggest starting with something where you don't give end users any input ability. Something like an image gallery, or a CMS where you as the site admin can create the content, but end users only get to see the finished pages.
If you're feeling more adventurous, you could write a guestbook app, or something like that, but be warned that you'll have to learn quickly all the security aspects of allowing end user input. You'll need to learn how to block spam, avoid SQL injection attacks, prevent cross-site scripting attacks, and a whole bunch of other stuff.
That's all important stuff to know about, but perhaps best left to your second project rather than your first.

Some common beginner tasks are:
- image gallery
- message board
- phone book
- simple forum
These simple projects will allow you to get accustomed to the languages and prepare you for the next steps: security, optimization, user experience, and maybe other.
I recommend trying something very simple at first and finishing it. Only after that you should start something bigger, or better still improve on your first project.

A simple blog platform would be a potentially good second or side project, with the opportunity for enhancement as your skills improve and incorporating things you'll learn from other smaller systems. Start from a single-user blog without comments, and build things up as you go along. Gives you some more free reign to play around on the design (HTML and CSS) side of things as well, and you can always throw in some simple JavaScript as well.
I'll say that #Alin's answers are some good potential starter projects as well, and #Spudley's answer is a good one.
And above all else - have fun!

I support a few of these. I would also suggest you look into doing something for someone else, say a small project. One think I find with myself and those I've taught is that it's a lot harder to commit to something when it's your own project. You also get caught up in the details. When you're doing it for someone else, though, it minimizes the chance.
Also look into using a MVC framework as a way to learn. Good MVC frameworks will allow you to play around while learning how classes work in PHP. I'm sure there are plenty of questions regarding them on SO.
Finally, if none of that leads you anywhere, think of something fun you'd like to try, not matter the difficulty, and go with that. Even if you don't complete a project, there's a high chance you learned something on the way, and that's worth your time.

You can start by reading and do some examples from here http://www.w3schools.com, they have good explanations for everything you want to use in html, php and css.m

Here are a couple suggestions:
Guest book
Simple client / project management

No PHP script could help you with html and css.
You have to master these things separately.
if you want to practice with html and css - just create an HTML page that represents one of your site/script pages and use it to train your html,css skills.
And it will have absolutely nothing to do with PHP part.
Just once you have finished with HTML, you will need to produce the same text dynamically.

Make blog. One step at a time:
On the main page articles one after another. Store them in files.
On the main page only 3 newest. Access the rest of them by menu.
Add option to create new articles.
Add option to edit or delete them.
Restrict access to these actions by using logins and passwords stored in file.
Add option to comment articles.
Add option to remove comments only by administrators (those logged with login and password).

Related

how to add comments to website

In an effort to give a website im working on more functionality, im wanting the ability for readers to post comments/thoughts to the stories they read.
any ideas the best way to go about this?
ive tried Google but the minute i add the word "comments " + html or php etc (assuming i can do it in these languages) then google just gives me methods to commenting on code....
Any ideas, tips, tutorials etc ill gladly jump on.
Thanks in advance
-somdow
Well the most popular embeddable comment system is probably Disqus. Besides that you will have to look if there are plugins for your framework of choice - or just roll your own (a comment system is basically just like any other database backed PHP application - and there are many ways to implement these).
Why not just look at how popular content management systems have implemented comments? (For instance, take a look at how Drupal and Wordpress do it.) The manner in which you build a comment system will depend on your needs and the limitations imposed by the structure of the system you're trying to integrate it with.
You should work out your database schema first. I'm assuming you're writing all of this from from scratch. You haven't given a lot of details.
It will be easier if you put your comments in a separate table. Make sure you have some basic protections against bots(captcha, etc.)
Sort the results by the timestamp.
comments_table
Id
UserId
UserDisplayName
ArticleId
Comment
PostTime
Disqus is nice, I must say. If you want code that you want to copy/paste, Google Friend Connect is a different route you can take... Almost everyone has a google account and it only takes a few minutes to set up. They also have some sweet other widgets you might want to try out like rating, etc.
http://google.com/friendconnect
If you really want to customize it just how you want it, I would create your own commenting system with a MYSQL database to store all your data. You could even use some nice jQuery animations when they write / delete a comment. (I just did something simular to that and it's really nice).
Whatever works best for you -- roll with it!
Good luck,
Coulton

Lost About where to start to become a web designer

i have long wanted to be a web designer, self taught. My aim for this year is to design a wordpress theme from scratch. i dunno where to start from.
learn photoshop, html, js, php, mysql in which order? where to get the learning resources etc.
what do i need to learn?
any advice will be hugely appreciated...
Are you aiming for designer or developer or both? A designer doesn't neccesairily need to be able to make a fancy AJAX page that does all sorts of mysql things. Mysql isn't needed at all for a designer.
Now if you wan't not only to design the template, but give a complete sollution to you customers your need to do a lot more.
The order I would do it would be:
photoshop / drawing / 'designing' ->
make the actual thing you want to
sell (the image, the 'vision' etc)
Some usability etc: Show your clients why your design is better,
why it's a good page and why your site 'works'
HTML: you can make a mock-up for your site so they can actually click
trough it. You can also sell this as a base for their programmers.
javascript, AJAX etc: You can make your mock-up better like this!
Now you want to sell complete templates (not just the design), you'll have to start learning the ins-and-outs of wordpress templates. that's kinda like a language an sich.
Get some basic PHP skills if you want, cause it can get you out of trouble, but it's not a big amount.
Mysql is only needed if you want to start adding functionality etc, but now you're really talking about a second job :)
In building websites there are different disciplines. In a nutshell:
Designer. Draws the website, how it should look. Defines the style of the website. Uses mainly PhotoShop.
Interaction Designer. Defines where each feature goes and how it should work.
Client side developer. Writes client side code. HTML/CSS templates, maybe a bit of JavaScript, although there is a big difference between HTML and JavaScript and the skills you need. Maybe you should even consider HTML/CSS and JavaScript to different disciplines.
Server side developer. Writes server side code (PHP/ASP/...). Will probably need some SQL knowledge as well.
Database administrator. Keeps the database running. Actually not part of the web-building disciplines list.
So, you need to think whether you want to be all these persons, or just one or a few of them. I personally so mainly PHP development and a little JavaScript. In work, I hardly do any HTML/CSS, because this is done by another guy. If you got a fellow that wants to build websites too, you maybe could check where each others skills lie. If you're a programmer, you can focus on serverside and JavaScript, where he can build the lot in PhotoShop, think about the interactions, and build HTML/CSS. You will only need a little of eachothers skills for sparring, and you could build great things together because each of you has their speciality.
If you need to do it on your own, and you haven't got any of these skills yet, I would just start somewhere and at least try everything. Keep your learning projects simple, and don't start mixing 5 of the names disciplines. If you want to start using HTML techniques, don't mind tha fancy looks yet. Draw a few lines in paint and just pretend you got all these gradients and spiffy looks. With a bit of make belief, if you try one of these skills you don't need any of the other ones.

CMS design patterns and considerations

I am creating the cms for a relatively simple site - portfolio, some general content pages, custom blog etc.
What are some of the best patterns to consider before diving into the design.
I want the system to be as flexible as possible without being too complex.
I have looked for some good resources that discus cms and blog design but can't find anything too good.
My language is php but I suppose I am looking for more language independent advice.
Flexibility without complexity... nice program.
Maybe you're a genius and you will make something that feet your needs. But I think the biggest problem you will face is security and robustness. So really, take other advices on this page and have a look at wordpress, drupal, joomla and ezpublish. A lot of security stuff is already done. And not only security...
So, study some of these tools, track their flaws, check their security policy. Study how they handle caching, sessions, bootstrap, absolute & relative url managment, documents (images, videos, etc), ajax, authentification, identification, acl, user interfaces, rich-text editing, migrations, templating, page composition, content filtering (I try to remove the things you won't need, plugins, database abstraction, fine caching, css and js minification, all the extra-complex stuff not needed for a single instance simple CMS). Soon you'll have a 'picture' of the stuff they've done.
By doing this work, you'll certainly notice some big differences, and mistakes. You'll start going on irc and flaming developpers, telling them that others have done better choices. You'll start forgetting to shave. You'll maybe do some contributions. Some will be accepted, others won't. Old core devs doesn't like when someone explain why they made mistakes (and they make mistakes).
Now, comes the day you have a beard. Some of your contributions will start looking like forks. You will have ennemies, and friends, or followers. And you will start feeling the force.
And you will go on irc and tell god that the world is ugly and that you'll make the first CMS which will be flexible without being complex. And people will cry. And birds will run in circles. And you will be able to explain what are the design pattern of a CMS.
I am a user. I know what I want. Doing what I want will make user happy. I'm happy.
You shall not trust code from people with glasses
"MVC MVC MVC" : and the people responds 'that shall be done'
Seriously, There's still a place for a good CMS with disruptive innovation, the fork history has started long time ago with phpNuke (as far as I can remember). But some of the actual products are really fine for most tasks.
I'm probably risking the reputation here, but my experience shows that building your own CMS can be a very justified decision, especially when you get familiar with current opensource systems and understand what exactly they lack in terms of features, security or what not. Open-source often means a lot of backward-compatibility concerns and bad architecture decisions that cannot be easily changed.
I strongly suggest that instead of just taking on MVC you take a look at ideas that make it attractive.
One main problem with CMSes is the range of technologies involved in driving dynamic web-sites: imperative php for logic, declarative SQL for data queries, markup HTML for interface, imperative/functional javascript for dynamic interface, JSON for ajax calls etc. To keep the system manageable you have to keep these technologies in a controlled and understandable environment, but yet allow for smooth integration. Knowledge and best practices are out there. MVC is but one approach to manage this problem.
My choice at the time was to use the following principles:
Object-oriented code with static calling (php is a one-run thing, many instances of code objects are rarely justified), nothing except for one line of init code in global context
100% code-design separation with the use of XSLT and custom content processor
Custom router that can take any http request and reroute it to registered methods
Custom content processor that can take arbitrary method output and convert it into any usable format such as xhtml, xml, json etc. based on the request parameters (i.e. http://local/class/method.xhtml, http://local/class/method.json)
One copy of code for as many virtual web servers as necessary
SQL query builder (chosen for flexibility over ORM) for all database queries
Mandatory filtering of method input with filter_* functions
I believe you can choose a few that you like :) And good luck!
A good pattern to start with is the Model View Controller pattern, or MVC.
This pattern suggests to seperate your application's logic in the following layers: data logic(model), manipulation or business logic (controller) and display logic (view).
This is a good pattern to start with as you'll run into other problems (and thus patterns) along the way.
The following website explains the MVC concept quite well: MVC Principles
There is no point reinventing the wheel unless you are trying to better it in anyway.
THere are a lot of CMS available already. I personally have worked with ezpublish. There are other options such as drupal etc. This is the list of all open source cms avaliable - Click here
If you are just trying to learn then you can perhaps pick any one of the popular opensource and work on them to find its architecture and design.
Besides, I dont think anyone can give you a list of design patterns that would be best for a CMS tool. Because each design pattern solves some particular problem. And, you just have to choose a design pattern depending on a specific problem you want to solve in your project.
These days, writing your own CMS is a horrible waste of time. The usual open source solutions -- these days Joomla, WordPress and Drupal are popular -- are written by thousands of people and while you might loose a little flexibility by using on that's ready made this is by far offset by not needing to redo everything from scratch. If you go with Drupal, you can also enjoy high quality, massively scalable etc code :)
If Your rquiremnt is portfolio, some general content pages, custom blog only, Wordpress will be simple and Better.
In PHP so many CMS available , most popular one is Joomla.

How do I design a simple web application?

I have basic knowledge of PHP and had done a few small personal projects before. Since my programs were small and usually consisted of less than five classes, I jumped into coding right away -- thinking of my database tables and user interface design as I went along. The problem was that I often found myself lost in my own ideas at the middle of my project. Hence, I thought that some form of formal planning would be practical to begin with.
I have been reading several software engineering books lately. One book said that, in web engineering, agile processes such as extreme programming and scrum should be used. I was introduced to tools such as use cases, CRC cards, and UML -- all I believe are too complicated and impractical for the simple projects I have in mind.
On the other hand, a web article I read simply suggested a rough sketch of the UI, a sitemap, and a simple workflow diagram. They seemed practical but too rudimentary and informal.
What would be a practical but formal approach to building a simple web application?
Don't be so quick to discard use cases, or some similar concept, e.g. 'user stories'. The benefit these tools bring is to make you think about what the site needs to do. That can guide all the further technical work, and help you focus on what's important instead of getting lost in interesting but low-value work.
Think about the top n things the site needs to do, and for each of these list out:
the ultimate goal for the user in this particular case
the kinds of people and other systems involved (actors, in use-case terminology)
what needs to be in place before starting this activity (the preconditions)
the basic steps the primary actor needs to perform to successfully achieve the goal
what should happen if one of those steps can't be completed
what the system looks like if the case is successfully completed (the postconditions)
what the system should look like if there were errors along the way
With a handful of these use cases, you can get an overall feel for what needs to be built to fulfill the goals. If it starts to look like too much work, you can look at which goals are of greater or lesser importance, and cut or defer those that provide less value. And if you think of new things the site should do, the existing use cases either:
provide a home for that feature, so modify the appropriate use case to incorporate the feature,
don't provide a home, indicating you missed a use case or discovered a new one, so you should elaborate on it as described above, or
don't provide a home, and therefore indicate the isn't necessary and so you shouldn't spend time on it.
The trick is to pick the proper level of abstraction and formality. Work at a high level, write informally, and you can knock these out quickly. When they're no longer useful (you have most of the application sketched out and are now heads-down working on details), put them aside. When you think of new things, see if they fit. Lather, rinse, repeat.
You have to ask yourself a few simple questions first:
1) Do I want to re-use and extend this code later?
If so, it may be a good idea to use some basic pattern such as MVC (Model-View-Controller) or use one of the many PHP frameworks available. The already established frameworks are more format in their design and how you use it. You could always use them as a basis to design your own as well.
2) Is the site you are making going to grow or change frequently? If the site isn't going to change much you could probably make something very simple and not worry too much about good design principles.
3) Do you want to learn and apply some of the techniques you mentioned? If so, then go to town and try the different techniques and see which ones appeal to you.
These kinds of questions will help you decide how you want to decide you build your website.
Start small, mock up a few simple screens, their database structure, etc. Use whatever method works for you - if that is UML diagrams, then fine. Get something finished, evaluate, and iterate from there.
This may not be quite what you are looking for, but also do yourself a favor and choose a framework such as CodeIgniter to make your life easier writing your server-side code. And similarly, consider using a client-side framework such as jQuery. This will make it easier for you when you are ready to actually sit down and write the code.
The Bare Essentials
I find there is a (roughly) four-step process that make application development a lot easier, and helps me avoid getting lost along the way. I make no pretense about using agile development methods. This is just the way I work.
Decide what the application needs to do. By "need", I mean, absolutely must do and nothing else. If it's a "nice to have" feature, write it down and come back to it later.
Figure out what data you need to keep track of to make everything work. Slugs, titles, datetimes, etc. Design the database. (I use MySQL Workbench for this.)
With your feature shortlist, prototype a user-interface with Balsamiq. Remember to add only the features you need right now.
You might consider doing HTML / CSS templates in this step.
Now that you have the data model and the UI, connect them. Business logic should focus on two things:
Abstract away from the data model so you can easily retrieve and store information from step 2.
Make the UI work exactly as you designed in step 3. Don't get fancy.
Focus on Small Goals
There are two keys to the process. The first is to to separate the design of various components. You don't want to be thinking about implementation details when designing the UI, etc. The second key is to iterate. Focus on exactly what you need to add right now and ignore everything else.
Once you're done, you can iterate and tweak, repeat steps 1-4, etc. But don't get stuck in any step for too long. You can always iterate again later if things don't turn out exactly as you like. (I think agile calls the iteration "sprints", but I'm not up on the theory.)
Practical Considerations
It helps if you have a light framework (at minimum) to assist with 4.1 (ORM, like Propel) and 4.2 (JQuery, etc.). You want to keep both the UI and data access as modular and compartmentalized as possible so it's easy to change later.
If you mix everything into one chunk of code, then you'll have to change every part of the program just to (for instance) add a new column to the database or add a new button to your app. You've had some experience, so you should have an idea of pitfalls to avoid.

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.

Categories