Posts Tagged ‘PHP’

Comment WordPress Contact Forms - 02/18/09

Generating a contact form for a website can be a rather tedious job. To make things easier there are a number of WordPress plugins available, one in particular which is rather good is Contact Form 7. This allows you to create a form and generate a number of tags for display on that form, e.g. email address, name, comments…

contactform71

You can then include this on your WordPress site via a new post or page using the following syntax:

 PHP |  copy |? 
[contact-form 1 "ContactForm"]

It supports CAPTCHA, simple quizzes, various different components for generating surveys, contact forms etc… It also supports localization of messages so that you can customize the error messages and text displayed.

One issue I did find with it however was that I wanted to embed the contact form in a template. At first this doesn’t seem to be possible unless you use another plugin. I used Improved include page which allows you to include a wordpress page in a template. By creating a new page with a contact form embedded it’s very easy to include this page in your template:

And you have a contact form which can be embedded in the footer of your page or wherever you choose to put it.

Comment PHP, Apache, Windows (Grrr) - 10/12/08

Posted under Design and Architecture by admin on Thursday 17 July 2008 at 2:22 pm

Ok just a few quick notes on stupid Apache, PHP and stupid Windows I wanted to share with people. If you ever have to setup Apache and PHP on Windows there are a few caveats you need to be aware of, especially if you require VirtualHost support for multiple domains. The reason I chose to do this is because I host websites at home on a Centos installation but have an archaic Medi@ TV server by Packard Bell that serves media files via a Powerline network. This means I have to boot into Windows to use it, I haven’t tried sorting this out via Wine yet but I don’t fancy my chances of getting it working. Whilst I’m at it, don’t buy one of these Medi@ TV boxes if you have a 64 bit processor, it just won’t work, plain and simple, I’ve got it running on an old AMD Duron proc. I found a need little driver called Ext2 IFS which allows you to map your Linux EXT2 partitions from Windows. Since I host both O/S’s on the same box this was a requirement. It’s straightforward and works out of the box, this means I could have the same DocumentRoot in the same place in Linux and Windows and be able to write to the DocumentRoot from either O/S. Grade. Apache frustrates me under Windows, the install is straightforward, the setup of the Windows service is pretty straightforward but the error reporting is just plain old stupid.

Service install is achieved via:

 PowerShell |  copy |? 
apache -k install

Service uninstall is achieved via:

 PowerShell |  copy |? 
apache -k uninstall

If you ever have problems with old stray Apache services (or indeed any services under Windows) then you might need to hack your registry and delete a few keys specifically from:

 PowerShell |  copy |? 
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services.

Anyways, that was the first issue. Secondly is the setup of php which should be pretty straightforward. In fact, in hindsight make sure you use the Windows installer rather than the zip file and configuration by hand. It adds the following to httpd.conf:

 PowerShell |  copy |? 
PHPIniDir "D:\\php\\" LoadModule php5_module “D:\\php\\php5apache2_2.dll”

However, make sure that you add the relevant entry to DirectoryIndex:

 PowerShell |  copy |? 
DirectoryIndex index.php index.html

to serve php files. Also:

 PowerShell |  copy |? 
AddType application/x-httpd-php .php .html
AddType application/x-httpd-php .php

to handle the php file type, alternatively modify mime.types under conf and add:

 PowerShell |  copy |? 
application/x-httpd-php php application/x-httpd-php-source phps

You might need to modify php.ini to point to your Apache installation and also to point to your DocRoot:

 PowerShell |  copy |? 
doc_root = "r:\www\html" extension_dir =”D:\php\ext”

And you might need to tweak:

 PowerShell |  copy |? 
upload_max_filesize = 2M

if you’re uploading files from forms. PHP all done. Finally back to Apache to sort out my VirtualHosts for my multiple domain names. First configuration of a name based virtual host and default host:

 PowerShell |  copy |? 
NameVirtualHost *:80
DocumentRoot “R:\\www\\html”

and my set of virtual hosts setup per domain:

 PowerShell |  copy |? 
<VirtualHost _default_:80>
DocumentRoot "d:\\workspace\sanctuary7website"
</VirtualHost>

Note that DocumentRoot has to have the \ escaped \\ under Windows. Doh. All done, up and running.

|