I’m working on a new web site for the company I work for. I have a test version setup in a test folder so I can test stuff without affecting the production sites. The old site was statically built pages, created nearly a decade ago and looking very tired, so I decided it was about time to spruce it up a little.
Now, to be fair, I’m not a designer, nor am I a web developer. Creating a web site is fun but not something I am paid to do as a profession. Because of this, I decided that I would let someone else do all the heavy lifting and downloaded bootstrap and a template (modern-business) then set about customising it.
Problem is, I ended up with a massive amount of duplicated code too. I needed to split this stuff out in to include files so a change to a menu was one file rather than 20 to change. That’s when I started thinking about a server based technology and came up with PHP. Well, “came up with” isn’t entirely accurate. The two web servers that this site is intended to end up on support PHP but not ASP.Net, so the decision was kind of taken away from me.
The journey to get the web site set-up proved fairly fun with a few minor frustrations along the way. My best friend has proved to be young Google who seems to know everything I need to know, which is pretty useful.
Biggest pitfall so far has been finding out those little niggles that none of the tutorials seems to tell you… Take this code for example:
if (strlen($contactEmail) == 0)
showWebForm($contactName, $contactCompany, $contactPosition, $contactPhone, $contactEmail);
setcookie('wcContactName', $contactName, time() + 60 * 60 * 24 * 30);
Nothing special, make a decision, include the registration form code file, call the code to display the registration form and then set a cookie to say we’ve done it.
I spent one and a half hours making that work.
Moral of the story. If you want to set a cookie, you must do it before you write anything to the web page. If you have output anything then the cookie is not written.
Wish one of the many books and articles I read and mentioned that one.