[phorm] [Phorm:] Phorm setup example

  • From: webbbs@xxxxxxxxx
  • To: support@xxxxxxxxx
  • Date: 28 Mar 2003 06:45:02 -0000

The following new message has been posted on Phorm Support Forum at 
<http://www.phorm.com/support/>. 

*************************************************************************** 

  MESSAGE:  (#2462) Phorm setup example 
            <http://www.phorm.com/support/?rev=2462> 
  AUTHOR:   Patrick O'Hara 
  DATE:     March 28, 2003 at 1:45 a.m. EST 

======================================================== 
NOTE: PLEASE READ THE DOCUMENTATION BEFORE CONTINUING 

This is not the only way to setup phorm, this is just an example and it 
happens to be the way I do it. I am often setting up websites that have a lot 
of forms, and this is how I manage all the information. 

This is not a replacement for the documentation supplied, it just gives an 
example of the application of the documenation. Please read the documentation 
before reading the remainder of this topic. 

Written By: 

Patrick O'Hara 
WhitsundayIT 
QLD, Australia 

patrick@xxxxxxxxxxxxxxxx 
www.whitsundayit.com 

NOTE: PLEASE READ THE DOCUMENTATION BEFORE CONTINUING 
======================================================== 

Dear Phorm Users, 

There have been a few people who have been asking about file locations and so 
on, and some details on installing and setting up Phorm. As always on this 
forum, when formatting is important I use >> to indicate a tab character. 
Wherever you see me write that, replace it with a tab in your file. 

This topic is split into seven sections: 

Step One 
Step Two 
Step Three 
Step Four 
Directories 
Advanced 
Summary 

Step One: 
======== 

I create a directory in my website document root called (funnily enough) 
"phorm" and copy the Phorm installation to that folder. The site-root relative 
URL to phorm.php is therefore always 

"/phorm/phorm.php" 

Step Two: 
======== 

I have shown two different forms here to use as an example later on. This is 
for example a contact form and a suggestions form, in two different html 
documents. These html documents do not have to be in the phorm directory, they 
can be anywhere in your web document tree. Note the differences between them 
and the similarities, these are explained later. 

<form action="/phorm/phorm.php" method="post" name="form"> 
<input type="hidden" name="PHORM_CONFIG" value="config.php"> 
<input type="hidden" name="PHORM_NAME" value="foo"> 
<!-- other form fields here, including submit button --> 
</form> 

<form action="/phorm/phorm.php" method="post" name="form"> 
<input type="hidden" name="PHORM_CONFIG" value="config.php"> 
<input type="hidden" name="PHORM_NAME" value="bar"> 
<!-- other form fields here, including submit button --> 
</form> 

Step Three: 
========= 

I now have the form set up and pointing to the phorm.php script. I then set 
phormconfig.php3 to contain the following: 

<?php 
$PHORM_RCONFIG = "Y"; 
?> 

Thats it. Why? Setting $PHORM_RCONFIG to "N" means that a form specific config 
file is not required. I want to require that file, so I set it to yes to 
remind myself that this is the case. (You could find it confusing if you open 
this file and it is blank!) 

Step Four: 
========= 

That is the installation directory covered, the forms covered, and 
phormconfig.php3 covered. Now - refer to the two form examples I gave above, 
note the differences. The only difference is the value of the hidden field 
PHORM_NAME. The reason for this is I use phormbase.php3 to change the working 
directory. 

In the phorm directory (where phorm.php is) I create a directory for each 
form. I like to call the directory the same as the value of PHORM_NAME. The 
nice thing about this is that all the files that relate to one form are all 
together in one folder. 

After phormconfig.php3 is read, Phorm knows it must see a form specific config 
file. It then changes the working directory as specified by reading 
phormbase.php3 which is set to: 

foo >> foo 
bar >> bar 

This looks nice doesn't it. This tells Phorm... 

if PHORM_NAME is foo change to /phorm/foo/ 
if PHORM_NAME is bar change to /phorm/bar/ 

....Phorm will then search that directory for a file called config.php and 
will start using that for the config settings. foo has a file called 
config.php and bar has a file called config.php which makes it easy to 
remember file names. All you have to remember is that you need to be looking 
in the directory with the same name as PHORM_NAME. Simple. 

Directories 
======== 

/phorm/ 

Contains the script and the first section of settings for Phorm. 

/phorm/lib/ 

This is where you put the fileattch.php3 and fileupload.php3 files when you 
register your copy. Registration is only $10, a very small price to pay to 
support the development of such a powerful program. This is the registration 
URL: 
http://www.phorm.com/register/ 

/phorm/plugins/ 

This is where you put the plugins you might download. Documentation on how to 
activate plugins is in a file called docs.rtf in the plugins directory. 

/phorm/<each-form>/ 

This is where I put all my form specific files. This folder will include any 
of the following files. I keep the file names the same across all 
form-specific folders to avoid confusion (as I mentioned with config.php 
above) 

/phorm/<each-form>/ack.html 
/phorm/<each-form>/config.php 
/phorm/<each-form>/email.txt 
/phorm/<each-form>/error.html 
/phorm/<each-form>/respond.txt 
/phorm/<each-form>/rules.txt 
etc. etc. etc. 

Advanced 
======= 

What you will be doing is specifying a form in a html document, and then 
calling /phorm/phorm.php to handle the submit. What if the validation fails. 
Phorm displays your error.html file. This probably says click back to correct 
these errors. 

How can you get it to open the original form, along with the error messages? 
The easy way is to recreate the form and insert the phorm error messages as 
outlined in the documentation. Now you have two forms, the original form and 
the error form. Both of which use the site relative link (and it is important 
that they use site relative links): 

/phorm/phorm.php 

Now you have two forms to maintain - if you change one you really must change 
the other. There must be a better way. There is: 

Instead of calling the error file error.html, call it index.html (remember to 
change the FILES section in rules.txt). Now, when someone clicks a link to a 
form, instead of going to 

/contact/index.html 

send them to 

/phorm/contact/ 

See what is happening? You have got one file, and when they click submit, it 
will call Phorm, and if there is an error it will REDISPLAY the form including 
the errors. The error lines will not show the first time - because the browser 
sees them as comments and ignores them. 

Summary 
======= 

You now have Phorm installed tidily on your website, with each form fully self 
contained in its own folder, and only one set of files to maintain! This is 
what I do, and it has saved me a lot of time and hassel trying to maintain 
related files in different places on the site. 

*************************************************************************** 

This is an automatically-generated notice.  If you'd like to be removed from 
the mailing list, please visit Phorm Support Forum at 
<http://www.phorm.com/support/>, or send your request to webbbs@xxxxxxxxxx  If 
you wish to respond to this message, please post your response directly to the 
board.  Thank you! 
-------------------------------------------------
You are receiving this message because you are subscribed to the Phorm mailing 
list. To send messages to the mailing list, simply send email to 
phorm@xxxxxxxxxxxxx from the address you have subscribed. You may unsubscribe 
from the list by sending email to phorm-request@xxxxxxxxxxxxx with 
'unsubscribe' in the SUBJECT field.

Other related posts:

  • » [phorm] [Phorm:] Phorm setup example