Implementing Form Script that Works with php 7

I recently upgraded hosting to php 7.0 since some of my WordPress sites were recommending the upgrade. The WordPress sites were fine, but one of my two last remaining HTML sites was using the Huggins Email Form php script, which isn’t compatible with php 7.0, and so the form started getting server 500 errors.

I looked up a resource I had used for a form for another HTML site, which was the ReusableContact Form Using Bootstrap And PHP.

Just download the zip file, and extract to the root directory for the site.

To test it, see the steps listed on the page where you got the zip file from.

To completely integrate it, I followed these steps:

  • Edit src/formhandler.php to change the email Subject and From.
  • Add any form field validations to handler.php.
  • If you’re using recaptcha, put the site key in the form (you’ll see the example in the formpage.html file), and put the secret key in handler.php.
  • Also, put the destination email address in handler.php.
  • Make sure you refer to the example formpage.html for including the link rels and script statements in the header and the recaptcha script in the body.

The next challenge was implementing a second form for that site. Fortunately the forms were on separate pages, so I didn’t need to use different form ids. I was able to use a generic Subject for both form emails, so no changes needed there. The second form worked fine. I suppose if I needed separate Subjects, separate recipients and separate field validation for each of the forms, then I’d need to figure out how to modify handler.php and formhandler.php. At some point, though, both of the remaining HTML sites will be converted to WordPress and I won’t need form scripts anymore!

 

Changing WordPress Max File Upload Size

I was Googling around, looking for an easier way to change the max file upload size when uploading files to the WordPress Media library and ran across this post on Brian’s Tips and Tricks for Web Developers website.

You can easily change PHP values by going to the Select PHP Options page under Select PHP version in the Software section of cPanel. When you’re on the Select PHP version page, choose Switch to PHP Options at the top right.

Click on the value, make a selection, Apply and Save.

Reducing Email Spam

reducing email spamA client recently contacted me about the large amount of spam emails he’d been receiving through the contact form on his website. Sure enough, when I took a look at his email, he’d been receiving 30-40 every day. They were all ads for various designer purses or other products.

The site was using GoDaddy’s webformmailer script to handle emailing of the forms on the site. I found a php script that uses captcha and implemented it on both of the forms that the website uses. Next I renamed the webformmailer script. When I checked a few days later, spam was down to about one per day. I found that some spam was still being received from cached versions of the html pages that used the scripts. Next step was to submit a request through Google Webmaster Tools to remove the old version of the pages. The client is now reporting that little or no spam emails are being received.

I do recommend contact forms versus just putting your email address on your website since spambots will pick up your email address and bombard you with spam.

Website Designers Should Document Code

Tip: Make sure the website designer’s contract/agreement for website design or maintenance services includes wording requiring the designer to document their work, especially for any customizations that are done. Designers should add comments to their code (Ex: PHP code, HTML code, CSS). This makes it easier for other designers and programmers who might also be looking at or working with the code. Website designers should document code because it will come in handy some time later when the designer works on the code again. Just a short phrase or reason describing why the edit was made can be very helpful and can save time.
I learned about documenting code in college while pursuing my Bachelor of Science degree and it is something I’ve always used.
By |December 28th, 2014|code, contract, CSS, HTML, PHP, website design|Comments Off on Website Designers Should Document Code