Just got done putting together a very simple form available for download that I decided to call BWT Simple PHP Contact Form. Simple name for a simple script.
BWT Simple PHP Contact Form as the name states is a simple contact form that can be implemented into any website, on any server that is running PHP5+.
All form validation is check by the server and contains no JavaScript and is written in the form of Object Oriented Programming (OOP).
That's about it really.
Please feel free to download the script and give it a go.
Click here to download
- Pete
Monday, January 18, 2010
Saturday, January 16, 2010
Simple OOP Form with PHP
Let's face it, as a developer, you WILL have to do some playing with PHP. It's just a matter of time and if you can't stand the language, you're gonna have to just deal with it. As PHP is still one of the most widely used server-side languages today, it's juts best to learn the language, and learn it the right way.
Now, when I say the right way, I mean, by using programming best practices as stated in my last blog about UML, MVC and OOP. This blog is about OOP in general and why it is the best and cleanest way to program your applications.
Below is a very simple example of PHP OOP and forms:
The PHP the class:
<?php
class HelloClass
{
public function sayHello($obj)
{
echo $say_hello = "Hello there " . $this->hello_name;
return say_hello;
}
}
?>
The HTML:
<form action="" name="hello_form" method="post">
Enter your name:<br/>
<input type="text" name="hello_name" value="" /><br/>
<input type="submit" name="hello_submit" value="Say Hello"/>
<input type="hidden" name="hello" value="true"/>
</form>
Define the objects:
<?php
$obj = new HelloClass;
$obj->hello_name = $_POST['hello_name'];
$obj->hello = $_POST['hello'];
$obj->sayHello($obj);
?>
The results:
Hello there "Name that was entered"
Ex: Hello there Pete
I know the code might be a bit messy on Blogger but feel free to download this example here.
- Pete
Now, when I say the right way, I mean, by using programming best practices as stated in my last blog about UML, MVC and OOP. This blog is about OOP in general and why it is the best and cleanest way to program your applications.
Below is a very simple example of PHP OOP and forms:
The PHP the class:
<?php
class HelloClass
{
public function sayHello($obj)
{
echo $say_hello = "Hello there " . $this->hello_name;
return say_hello;
}
}
?>
The HTML:
<form action="" name="hello_form" method="post">
Enter your name:<br/>
<input type="text" name="hello_name" value="" /><br/>
<input type="submit" name="hello_submit" value="Say Hello"/>
<input type="hidden" name="hello" value="true"/>
</form>
Define the objects:
<?php
$obj = new HelloClass;
$obj->hello_name = $_POST['hello_name'];
$obj->hello = $_POST['hello'];
$obj->sayHello($obj);
?>
The results:
Hello there "Name that was entered"
Ex: Hello there Pete
I know the code might be a bit messy on Blogger but feel free to download this example here.
- Pete
Friday, January 8, 2010
OOP, UML and MVC, What? and Why?
As a developer, there comes a time when you start to get deeper and deeper into learning new ways of writing and structuring your code. I've been doing TONS of research and playing around with some techniques that are of coarse well known but to be honest I'm not exactly sure who really uses them, at least and unfortunately many co-workers are quite clueless when it comes to these techniques.
The techniques that I am referring to are OOP (Object Oriented Programming), UML (Unified Modeling Language) and MVC (Model View Controller) which is basically a way to organize your stuff in a manner that you should already be doing in the first place.
First off, OOP. I can't be the only one that had a tad of trouble getting their foot into the door and actually understand what on earth this was and why it is so important when developing basically anything and everything from simple show a name applications to more complex applications where there are many functions firing off at the same time.
OOP is a beast and once you get it, you know because it hits you like a train, making you think, OMG I can do this and yes, yes I do understand it.
At first I began writing some functions thinking I was writing OOP even though all I was doing was creating a bunch of functions and firing a main function instead of creating any classes which means I was still technically writing procedural code, yucky.
But that one day came and I got hit by that train that made me say, Oh jeez I was doing this all wrong but thankfully I get it now and will continue to do it the right way.
Now for UML. This isn't exactly all that new to me in a sense because when I was handed a project I always always always created a simple diagram which included needed functions, database tables with row names, foreign keys and so on.
Thing is, I'm not sure anyone even uses this technique to build their applications and by all means if you do please let me know.
Finally MVC which let's be honest, you should be doing this technique no matter what because it makes sense. Like OOP, there are many developers that might have trouble understanding what this is and why they should really even bother with it. The truth is that you should and it helps greatly when applications start to get larger in scale and you need to scale your application with ease and ridden the possibilities of introducing big nasty bugs into them.
But what is MVC? It's simply a way to slice up the code for your application into sections that make sense. Model, View and Controller, which should be obvious of what they do but instead of me trying to explain it all, try reading the Wiki on it here...
Enough of my ramble, I plan on tossing up a few examples of some OOP concepts in some future blogs in a few different programming languages.
- Pete
The techniques that I am referring to are OOP (Object Oriented Programming), UML (Unified Modeling Language) and MVC (Model View Controller) which is basically a way to organize your stuff in a manner that you should already be doing in the first place.
First off, OOP. I can't be the only one that had a tad of trouble getting their foot into the door and actually understand what on earth this was and why it is so important when developing basically anything and everything from simple show a name applications to more complex applications where there are many functions firing off at the same time.
OOP is a beast and once you get it, you know because it hits you like a train, making you think, OMG I can do this and yes, yes I do understand it.
At first I began writing some functions thinking I was writing OOP even though all I was doing was creating a bunch of functions and firing a main function instead of creating any classes which means I was still technically writing procedural code, yucky.
But that one day came and I got hit by that train that made me say, Oh jeez I was doing this all wrong but thankfully I get it now and will continue to do it the right way.
Now for UML. This isn't exactly all that new to me in a sense because when I was handed a project I always always always created a simple diagram which included needed functions, database tables with row names, foreign keys and so on.
Thing is, I'm not sure anyone even uses this technique to build their applications and by all means if you do please let me know.
Finally MVC which let's be honest, you should be doing this technique no matter what because it makes sense. Like OOP, there are many developers that might have trouble understanding what this is and why they should really even bother with it. The truth is that you should and it helps greatly when applications start to get larger in scale and you need to scale your application with ease and ridden the possibilities of introducing big nasty bugs into them.
But what is MVC? It's simply a way to slice up the code for your application into sections that make sense. Model, View and Controller, which should be obvious of what they do but instead of me trying to explain it all, try reading the Wiki on it here...
Enough of my ramble, I plan on tossing up a few examples of some OOP concepts in some future blogs in a few different programming languages.
- Pete
Wednesday, December 30, 2009
Goals for 2010
Every year I make a list of goals to accomplish and lord knows that I have gotta try and do something because 2009 wasn't exactly a great year for myself.
5 Reasons 2009 sucked:
- Pete
5 Reasons 2009 sucked:
- Left a bad paying job for a relatively better paying job and went back to the bad paying job
- Lost 2 cars which led to trouble all over the place
- Lost a chance to work for a great company but lost that due to the economy
- Both brother in laws got into a bad car accident but thankfully survived
- Health insurance went up dramatically due to economy
- Saved a ton of money to help get out of debt
- Took a trip to the Carolina's to meet gf's grandparents and see brother in law
- Went to first developer conference. Was awesome!
- Bought a newer car
- Finally got my laptop after saving for way too long
- Secure a position with a company that pays their developers more then Walmart
- Continue to learn the languages that I have been studying
- Get a car that doesn't need it's oil checked ever other day
- Work harder at getting freelance service known
- Complete CMS Leo project
- Get married to my fiance of 13 years.
- Buy a house, buy a house buy a house
- Learn to relax a bit more and less stressed out
- Somewhere in there I'll also try and find time to drop a few pounds
- Pete
Tuesday, December 29, 2009
Get those images out of PowerPoint
Every now and then as a developer you get handed a disk or and email sent to you and someone says, here are those images that you need for the bla ba bliche project.
Problem is that once you toss the disk into the drive or open the email to get the files, all you see is a damn PowerPoint presentation. You may think at first that you're gonna have to save each image individually and before you even try to do something as silly as that give this little trick a go and see how you make out. It just may save you an hour or two or more of nonsense.
- Pete
Problem is that once you toss the disk into the drive or open the email to get the files, all you see is a damn PowerPoint presentation. You may think at first that you're gonna have to save each image individually and before you even try to do something as silly as that give this little trick a go and see how you make out. It just may save you an hour or two or more of nonsense.
- Get Open Office here and install that badboy once it's done downloading.
- Open the PowerPoint file with Open Office.
- Save the file as ODF Presentation .odp
- Now give the file a new extension of .zip
- You should now see a zip file, so how about we open it.
- Extract all the files in the zip file or just the Pictures directory.
- Your photos should now be available to you in the Pictures directory.
- Pete
Sunday, December 27, 2009
Love of a new language
More than recently I've been having a go with the Python programming language and must admit that I absolutely love the language and now that I received Programming in Python 3 by Mark Summerfield I feel that I can go full force into learning this wonderful language that doesn't seem to be going anywhere, anytime soon.
When I first heard about the Python language I remember watching a tutorial on YouTube where a Googler rambled on about some real intense programming stuff with Python and of coarse I had no clue what he was talking about at first. Of coarse this was before I started to dive into the OOP club and might not have even completed my first year of hands on experience and still writing procedural code.
Once I started getting the general idea about how to do the OOP thing I began to get more and more curious about other programming languages and thought it might be a good time to do a bit of fiddling with Python since it seems to be a very popular and unique language.
The syntax is very easy to read and understand and actually takes less code in some cases compared to other languages such as PHP, Java and C#, for instance:
PHP, C# and Java - if(apples == "nom nom nom") { // do other stuff }
Python - if apples == "nom nom nom"
And of coarse the data type thing that needs to be done in some languages, but not in Python, no need to define your data types there.
Basically, you can do anything and everything with the Python language that you can do with all the others with the possibility to write less code along the way also. Now, don't get me wrong, I don't have a care in the world how much code I gotta write but sometimes certain things just click and the Python language is doing just that with my brain at the moment.
P.S. - Thanks for reading this ramble and I am VERY aware that it's not at all informative :^)
- Pete
When I first heard about the Python language I remember watching a tutorial on YouTube where a Googler rambled on about some real intense programming stuff with Python and of coarse I had no clue what he was talking about at first. Of coarse this was before I started to dive into the OOP club and might not have even completed my first year of hands on experience and still writing procedural code.
Once I started getting the general idea about how to do the OOP thing I began to get more and more curious about other programming languages and thought it might be a good time to do a bit of fiddling with Python since it seems to be a very popular and unique language.
The syntax is very easy to read and understand and actually takes less code in some cases compared to other languages such as PHP, Java and C#, for instance:
PHP, C# and Java - if(apples == "nom nom nom") { // do other stuff }
Python - if apples == "nom nom nom"
And of coarse the data type thing that needs to be done in some languages, but not in Python, no need to define your data types there.
Basically, you can do anything and everything with the Python language that you can do with all the others with the possibility to write less code along the way also. Now, don't get me wrong, I don't have a care in the world how much code I gotta write but sometimes certain things just click and the Python language is doing just that with my brain at the moment.
P.S. - Thanks for reading this ramble and I am VERY aware that it's not at all informative :^)
- Pete
Sunday, November 29, 2009
CMS Project Update
Back in the very beginning of September I Blogged about a Content Management System project of my own that I have been trying to get started for a while now.
For a quick update, I have been working REALLY hard working on templates, tons of CSS and of coarse the list of features that seem to never stop growing (shocker there huh?).
Thus the reason that I must tell myself to calm down with the feature list and just get the base of the system down so I can continue to add onto it while I have a basic beta out for others to fiddle with and make their judgments.
In my previous Blog I also stated that I would be developing my CMS in ColdFusion but that has changed for the main reason of popularity. I know I know ColdFusion is a great language and I'll probably get hit with a lot of CFers's stating why I should use ColdFusion even though I haven't stated the language that I will be developing in.
Originally my CMS was suppose to be developed in ColdFusion as I stated above until I started to do some fiddling with Python and Django. Then I started developing a lot in PHP, I mean more than I have ever done before and started to feel more comfortable coding with PHP than ColdFusion. I can't believe I'm gonna say this but I actually liked developing in PHP more then ColdFusion. I blame this on the straight month of work that I was handed in no other than PHP.
I am not saying goodbye to ColdFusion at all, just saying sorry ColdFusion, not this project, maybe the next one.
So, PHP it is and I accept all the challenges that I come across during the development of my CMS project.
- Pete
For a quick update, I have been working REALLY hard working on templates, tons of CSS and of coarse the list of features that seem to never stop growing (shocker there huh?).
Thus the reason that I must tell myself to calm down with the feature list and just get the base of the system down so I can continue to add onto it while I have a basic beta out for others to fiddle with and make their judgments.
In my previous Blog I also stated that I would be developing my CMS in ColdFusion but that has changed for the main reason of popularity. I know I know ColdFusion is a great language and I'll probably get hit with a lot of CFers's stating why I should use ColdFusion even though I haven't stated the language that I will be developing in.
Originally my CMS was suppose to be developed in ColdFusion as I stated above until I started to do some fiddling with Python and Django. Then I started developing a lot in PHP, I mean more than I have ever done before and started to feel more comfortable coding with PHP than ColdFusion. I can't believe I'm gonna say this but I actually liked developing in PHP more then ColdFusion. I blame this on the straight month of work that I was handed in no other than PHP.
I am not saying goodbye to ColdFusion at all, just saying sorry ColdFusion, not this project, maybe the next one.
So, PHP it is and I accept all the challenges that I come across during the development of my CMS project.
- Pete
Subscribe to:
Posts (Atom)
