So I was up late last night making some tweaks to my blog theme and realized that now would probably be a good time to share some of my PHP knowledge with new Domainers. PHP is an essential language to know when working with WordPress and comes-in handy for building your own sites as well. The great thing about PHP is that it is nowhere near as complicated as a programming language like C++ or Java so you can learn and begin using PHP very quickly.
So for the month of June I will be doing a four-part series on PHP that will get you up and running without having to read one of those “Learn PHP in 24-hour” books. I think PHP is an essential language for any Domainer that is also a developer. As more and more Domainers start blogging or developing mini-sites PHP will continue to become increasingly important. If you’ve ever been confused by the inner-working of your WordPress themes I hope this helps to allow you to customize your themes beyond the WordPress GUI.
So let’s get started with the first lesson!
You can add PHP to an existing website easily by simply typing when you want to start writing “<?PHP” before your code and then
"?>" when you are done with your code. That’s it – put your PHP code between these two tags and you are ready to go. So time to learn your first PHP function – print. The code snipped below will write – “Hello Domaining World” on your site:
print “Hello Domaining World”;
If you put this into an HTML document and upload it to your server (given that is supports PHP which just about every hosting company has pre-installed) then you’ve just written your first working PHP code! Pat yourself on the back and we’ll move-onto something a bit more interesting.
Let’s cut to the chase and make something interactive. Where PHP really shines is interacting with HMTL forms. Now I’ll show you how to make a simple form on your website that you can then interact with using PHP – first let’s start with a basic HTML form:
<form method = “POST” action = “domainvestors_form.php”>
Name: <input type = “text” name = “username”>
Domain: <input type = “text” name = “domain”>
<input type = “submit” value = “Submit”>