[Pro] Integrating PHP into Freeway

Hi everyone

I’m trying to learn how to write scripts in PHP.

I’m using two books, one of which was recommended by this list. Actually writing the scripts is a fairly steep learning curve but my main problem so far is integration with the pages produced by Freeway.

One of the first exercises from the books was handling a form. Creating the form in Freeway was easy enough and passing on the entered data to the PHP script [METHOD=POST] was not too hard either. But sending back info from the script to a page in a browser seems limited to some very basic HTML. I don’t write HTML [I use Freeway!] so I end up with a few lines like “Thank you Fred, your feedback was very interesting” in an otherwise blank page in the browser. [using enough HTML learnt from examples in the PHP books!] It looks like I would need to know a lot more HTML before I can get a page in a browser that matches the kind of page I get using Freeway.

Assuming I’ve created [in this case] a “Thank You” page in Freeway that matches the rest of the site, how would I get the necessary response [i.e. the man’s name plus other details] from the PHP script into Freeway. Another scenario might be populating part of a Freeway created table with info from a PHP script.

Or am I totally wrong in this approach?

Thanks in advance for any replies/advice etc…

Wild Cottage.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

When doing something like this it can be better to have the PHP within the original page so you Post back to that page.

In saying that the php output from the PHP Feedback Form action can be tweaked to do this too.

Example http://www.deltadesign.co/formtest.html

Fill and submit to see it working either select attending or not

David


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

  1. What do you mean, ‘the mans name plus other details from a php
    script into Freeway’? do you want show the information that was
    entered on the form on the thanks page in Freeway?

There are ready made scripts and even Freeway actions that will take
all the hard work out of a contact form for you? the actions also help
take care of the forms being used to send spam which is something you
would be advised to build into your form and PHP scripts.

  1. To get the information from a PHP variable such as $name into a
    Freeway page you could simply write
<?php echo $name; ?>

But the script would need to be integrated with that page in some way
or the variable been sent to that Freeway page for it to have and show
it’s value.

I have some old FW4 Pro examples (will run on FW4 Pro and above) that
you can look at, there are a few there that shown one way of
integrating a PHP script with Freeway and how to use Markup items to
show dynamic text/items on Freeway pages:

Look at 1# and 2# on the following page:
http://www.easibase.com/freeway/phpmysql.php

HTH

On Jan 23, 2011, at 6:56 PM, WildCottage wrote:

Hi everyone

I’m trying to learn how to write scripts in PHP.

I’m using two books, one of which was recommended by this list.
Actually writing the scripts is a fairly steep learning curve but my
main problem so far is integration with the pages produced by Freeway.

One of the first exercises from the books was handling a form.
Creating the form in Freeway was easy enough and passing on the
entered data to the PHP script [METHOD=POST] was not too hard
either. But sending back info from the script to a page in a browser
seems limited to some very basic HTML. I don’t write HTML [I use Freeway!] so I end up with a few lines like “Thank you Fred, your
feedback was very interesting” in an otherwise blank page in the
browser. [using enough HTML learnt from examples in the PHP books!]
It looks like I would need to know a lot more HTML before I can get
a page in a browser that matches the kind of page I get using Freeway.

Assuming I’ve created [in this case] a “Thank You” page in Freeway
that matches the rest of the site, how would I get the necessary
response [i.e. the man’s name plus other details] from the PHP
script into Freeway. Another scenario might be populating part of a
Freeway created table with info from a PHP script.

Or am I totally wrong in this approach?

Thanks in advance for any replies/advice etc…

Wild Cottage.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Mike B and DeltaDave

Thanks for the replies. Certainly in the case of a form the action route sounds easier, but my question was really a general one.

Is it possible to take the results of a PHP script to populate a table created in Freeway? [for instance]

At this stage I’m just learning; results of forms would perhaps be better done through an “Action”. I’ll keep reading the books and see how I go.

Any other info on integration:

Quote

  1. To get the information from a PHP variable such as $name into a Freeway page you could simply write <?php echo $name; ?> But the script would need to be integrated with that page in some way or the variable been sent to that Freeway page for it to have and show it’s value.

Unquote

How would this be done?

Wild Cottage


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Add the Action PHP Use Include Pages[1] to the Freeway page where you
want your script to work. Give your page the .php filename extension,
or configure your server to parse all html files as if they were PHP.
The Action will write a require() statement to insert the code into
your page at the very top of the HTML file – before the DOCTYPE or
any other code is written, so you can use headers without fear. And it
will manage the upload of this code to your server, and maintain a
live link to the code so that any updates in your original trigger a
new upload to the server.

Make sure that you write your code so that it sets up variables with
values, rather than printing out results right then and there. For
example:

//not this
print 'Foo bar baz';
//or
echo $_POST['first_name'];

but rather this

$message = 'Foo bar baz';
//or
$first_name = $_POST['first_name'];

Then, further down in the visible part of your Freeway page, where you
want something to appear, you can do this inside a Markup Item or an
instance of the Crowbar Action:

<?= $message ?>
//or, if your server doesn't do "short tags"
<?php echo $message; ?>

You place that precisely where you want it to appear in the page, and
you can add a styled space on either side of the markup container to
give the resulting text some style.

Freeway’s markup elements are a pain in the posterior to do code
editing of any length beyond a few words, so using the Action lets you
write the bulk of your code in a proper programmer’s editor, and to
take advantage of debugging and syntax highlighting to make that part
of the job easier. It also encourages you to think modularly, to
package your code together into functions that you call or variables
that you print back, rather than a mish-mosh of intermingled logic and
presentation. You can leave your PHP script open in your editor, and
every time you update (and save) your script and then upload your page
to the server in Freeway, the new code will be used in your page. It’s
the best of all worlds.

Walter

  1. PHP Use Include Pages - ActionsForge

On Jan 23, 2011, at 2:01 PM, WildCottage wrote:

Hi Mike B and DeltaDave

Thanks for the replies. Certainly in the case of a form the action
route sounds easier, but my question was really a general one.

Is it possible to take the results of a PHP script to populate a
table created in Freeway? [for instance]

At this stage I’m just learning; results of forms would perhaps be
better done through an “Action”. I’ll keep reading the books and see
how I go.

Any other info on integration:

Quote

  1. To get the information from a PHP variable such as $name into a
    Freeway page you could simply write <?php echo $name; ?> But the
    script would need to be integrated with that page in some way or the
    variable been sent to that Freeway page for it to have and show it’s
    value.

Unquote

How would this be done?

Wild Cottage


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

If you look at the examples I sent you in the link you would see how
to do what you ask…

you can then extend that to using actions to include scipts etc. if
you wanted to although you don’t have to.

On Jan 23, 2011, at 8:01 PM, WildCottage wrote:

Hi Mike B and DeltaDave

Thanks for the replies. Certainly in the case of a form the action
route sounds easier, but my question was really a general one.

Is it possible to take the results of a PHP script to populate a
table created in Freeway? [for instance]

At this stage I’m just learning; results of forms would perhaps be
better done through an “Action”. I’ll keep reading the books and see
how I go.

Any other info on integration:

Quote

  1. To get the information from a PHP variable such as $name into a
    Freeway page you could simply write <?php echo $name; ?> But the
    script would need to be integrated with that page in some way or the
    variable been sent to that Freeway page for it to have and show it’s
    value.

Unquote

How would this be done?

Wild Cottage


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Mike B & Waltd

Many thanks for your input!

I will go away and try the suggestions. A deeper look at the example Mike B, and thanks for the insight Waltd.

I was starting to hit a brick wall; now the pain is going away.

Thanks again.

Wild Cottage.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

@ The Big Erns

Is this template available to download or is this just a sample? I love your work - you did a great job!!

Thanks,

Peter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options