How to pass a form value from one page to another

How in FreewayPro 4.3.2 can I get a formfield which a user has filled-in on a webpage (say a radiobutton or checkbox selection, or some other formfield) to be passed into a form on another page?


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

I have an example of this using a php form, see:
http://www.easibase.com/freeway/phpmysql.php

Your are loooking for the ‘Passing php values’ example, number 2 on the page. There is also an example file you can download.

HTH


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

Hi Mike

I downloaded your example file, un-zipped it into a newly-created folder, and set that as the site folder, but when I tried to preview it I got a warning “One or more HTML files which do not belong to this site will be overwritten. Do you want to continue?”

Not wanting to take the risk (!) I say No.

How can I avoid the risk???


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

Just make sure that new folder is selected for the publishing of the files, if it is then don’t worry as it will be only overwriting any of files already there from the download, it would be more of a problem if you had one of your other site folders selected and it was going to overwrite those.

HTH


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

I risked it!!

Now, I think I have an idea, but not quite the correct one!!

I’ve created a page at www.personality.co.uk/test/gofrompage.html
which has a single textfield called ‘email’ and a Submit button.

Using FormsToGo I’ve made the form work so that a successfully-validated email address in the ‘email’ field, followed by a press of the ‘Submit’ button, takes the user to a page called ‘www.personality.co.uk/test/gotopage.html’ on which is a Markup item containing the following:

<?php $name = $_POST['email']; if (trim($name)==' ') { $error = 'Error! No email!'; // Let's see if we have an error if ($error) { echo $error; } else { echo 'Your email address is: ' . $name; } ?>

The user is taken to ‘gotopage.html’ but no text appears echo’d on it.

Do I have the correct idea? What needs to be done to make it work?

Thanks. PHILIP


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

You have a syntax error, but your server is in “production” mode, and
is suppressing errors. Unless you use a programmer’s editor like
TextMate, which can validate any sort of code for you by running it
through the command-line on your Mac, you will need to turn on error
reporting in your script to see these problems.

In your case, the error is this – you have an open brace ‘{’ in line
3, but you don’t close it ever. So the closing brace in line 10 (which
you intend to close the brace you opened in line 6) is taken to close
the brace opened in 3, but that leaves the script hanging at the end.

If you add a closing brace in line 5, your script will work.

To be able to see these things for yourself, add the following lines
to the top of your script:

ini_set('display_errors',1);
error_reporting(E_ALL);

Walter

On Feb 1, 2009, at 11:12 AM, Philip Caplan wrote:

I risked it!!

Now, I think I have an idea, but not quite the correct one!!

I’ve created a page at www.personality.co.uk/test/gofrompage.html
which has a single textfield called ‘email’ and a Submit button.

Using FormsToGo I’ve made the form work so that a successfully-
validated email address in the ‘email’ field, followed by a press of
the ‘Submit’ button, takes the user to a page called ‘www.personality.co.uk/test/gotopage.html
on which is a Markup item containing the following:

<?php $name = $_POST['email']; if (trim($name)==' ') { $error = 'Error! No email!'; // Let's see if we have an error if ($error) { echo $error; } else { echo 'Your email address is: ' . $name; } ?>

The user is taken to ‘gotopage.html’ but no text appears echo’d on it.

Do I have the correct idea? What needs to be done to make it work?

Thanks. PHILIP


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 are only sending the value from one page to the other you do not need forms to go, now depending on what form handling action or process and actions you are using and what you want to do with the values will depend on how you create the process.

If the second page has no process for retrieving the variable values then add an instance of the PHP Form Action to that page, * from what you say this could be your problem *.

You just need to be careful as to what you are doing, in the sense that: if you use an action or forms to go you are sure you are not doubling up or conflicting on something any form action or/and * other * form handling process is doing.

If you have three pages, two are forms, the first sends a value to the second with the second sending a contact email, the third being a thanks page:

Form one: Needs to have a field, fields and/or other elements the use fills in and sends to your second form. This first form generally needs to have a method of POST and the url of the second form set in the form action.

Form two: Needs to have a field, fields and/or other elements with the same name as your first form so those entered values will appear there, you can have other elements that the user then fills in.
This form generally needs a method of POST, and action url and a way of retrieving the values sent from the first form, the latter may already be set depending on what form processing Action you use, if not then apply the PHP Form Page Action to the page and that will set any php code needed to pick the values up.

I would guess that if you apply the PHP Form Page Action to the second form you will then see the values passed on.


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

Forgot to add – remove these when you’re done testing, they’re a
security risk, which is why your server is suppressing them.

Walter

On Feb 1, 2009, at 11:31 AM, Walter Lee Davis wrote:

ini_set('display_errors',1);
error_reporting(E_ALL);

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

Only if you also add the form elements to your page as hidden
elements. And then, I’m not sure if the Action looks for those kinds
of fields. I’ll have to take a look at the code later.

So if you were making a multi-stage form, and you only wanted to store
the result of someone going all the way through to the final page, you
would do this:

###Page 1 (submits to page 2):

[name] <- text field
[rank]
[serial number]
(Submit) <- button

###Page 2 (submits to page 3):

<name> <- hidden field
<rank>
<serial number>
[shoe size]
[favorite color]
[nickname]
(Submit)

Those hidden fields need to be filled in with the values that were
passed on from page 2, so if the PHP Form Action can fill them in for
you, then you’re golden – just make the hidden elements, apply the
Action to the page, and move on.

###Page 3

//receives the following
Array(
	name => 'Fred',
	rank => 'Corporal',
	serial_number => '12345',
	shoe_size => '12',
	favorite_color => 'blue',
	nickname => 'skippy',
	submit => 'Submit'
)
//decides to show either success or failure

On this page, you would have the form handler logic (and you could
substitute this for any FTG-generated handler, as long as it “knew”
about all of the fields – hidden and visible – that are being sent
to it.

Walter

On Feb 1, 2009, at 11:36 AM, Mike B wrote:

I would guess that if you apply the PHP Form Page Action to the
second form you will then see the values passed on.


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

Open the PHP Form Action in a text editor, move to line 313 and change
it from

var validTags = new Array("SELECT","INPUT","TEXTAREA");

to

var validTags = new Array("SELECT","INPUT","TEXTAREA","HIDDEN");

And it will magically set hidden fields to play back PHP values.

Walter

On Feb 1, 2009, at 12:05 PM, Walter Lee Davis wrote:

And then, I’m not sure if the Action looks for those kinds of
fields. I’ll have to take a look at the code later.


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

Sorry, it’s not that simple. I’m fixing it now, and I’ll post it to
ActionsForge in a moment.

Walter

On Feb 1, 2009, at 12:10 PM, Walter Lee Davis wrote:

Open the PHP Form Action in a text editor, move to line 313 and
change it from

var validTags = new Array(“SELECT”,“INPUT”,“TEXTAREA”);

to

var validTags = new Array(“SELECT”,“INPUT”,“TEXTAREA”,“HIDDEN”);

And it will magically set hidden fields to play back PHP values.

Walter

On Feb 1, 2009, at 12:05 PM, Walter Lee Davis wrote:

And then, I’m not sure if the Action looks for those kinds of
fields. I’ll have to take a look at the code later.


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

http://www.actionsforge.com/actions/view/1-php-form-action-page

On Feb 1, 2009, at 12:10 PM, Walter Lee Davis wrote:

Open the PHP Form Action in a text editor, move to line 313 and
change it from

var validTags = new Array(“SELECT”,“INPUT”,“TEXTAREA”);

to

var validTags = new Array(“SELECT”,“INPUT”,“TEXTAREA”,“HIDDEN”);

And it will magically set hidden fields to play back PHP values.

Walter

On Feb 1, 2009, at 12:05 PM, Walter Lee Davis wrote:

And then, I’m not sure if the Action looks for those kinds of
fields. I’ll have to take a look at the code later.


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

I’ve been away from my computer for an hour or two, and now I’m back you guys have really confused me! :slight_smile:

Firstly, Walter, where you said:

I tried what you said and also put in the 2 lines ini_set(‘display_errors’,1);
error_reporting(E_ALL);
but I’m still not getting a result. Could you kindly post here the complete correct text, perhaps I’ve put the missing } in the wrong place!

Now, the rest of the thread is what’s confusing me!

What I want to achieve at the moment is that somebody goes to a sort-of-gallery page on my site where they are shown lots of pictures; they select one by clicking a radiobutton underneath it; they click a link to take them to a “place-an-order” page (which I already have working) on which is a form, and the “picture_id” field on that form is filled with the value of the one they chose. They can then complete the rest of the formfields, and click “Submit” to send the form data.

I chose to purchase “Forms To Go” (FTG) for my form-processing code generation, due to recommendations on this forum, and I’ve found that (after a little learning with help from Bebosoft’s forum/help) it works excellently for me.

My current need is for the field contents to be sent to me as an email, with “success” and “failure” landing pages, and it does this perfectly. I’m even able to offer a “Browse…” button to select a file as part of the form, and have that file sent to me as an attachment to the email sent, so I’m a happy bunny there!

I very much appreciate Mike B’s help to me here, as he sells the competing “EasiForm” for $20US, and Mike I’d happily pay you for that if you want, but at the moment FTG is covering my needs well, and I can see benefit in keeping the form-handling outside of FWPro’s action-based operation. At the least, it’s wiring my brain up to understand the two sides more clearly!

So, if you two can help me understand how to get the field content from my “sort-of-gallery” page into a formfield on the next “place-an-order” page, that would be wonderful!

Many thanks. PHILIP


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

On 1 Feb 2009, 5:32 pm, Philip Caplan wrote:

I’ve been away from my computer for an hour or two, and now I’m back you guys have really confused me! :slight_smile:

Firstly, Walter, where you said:

I tried what you said and also put in the 2 lines ini_set(‘display_errors’,1);
error_reporting(E_ALL);
but I’m still not getting a result. Could you kindly post here the complete correct text, perhaps I’ve put the missing } in the wrong place!

Now, the rest of the thread is what’s confusing me!

What I want to achieve at the moment is that somebody goes to a sort-of-gallery page on my site where they are shown lots of pictures; they select one by clicking a radiobutton underneath it; they click a link to take them to a “place-an-order” page (which I already have working) on which is a form, and the “picture_id” field on that form is filled with the value of the one they chose. They can then complete the rest of the formfields, and click “Submit” to send the form data.

I chose to purchase “Forms To Go” (FTG) for my form-processing code generation, due to recommendations on this forum, and I’ve found that (after a little learning with help from Bebosoft’s forum/help) it works excellently for me.

My current need is for the field contents to be sent to me as an email, with “success” and “failure” landing pages, and it does this perfectly. I’m even able to offer a “Browse…” button to select a file as part of the form, and have that file sent to me as an attachment to the email sent, so I’m a happy bunny there!

I very much appreciate Mike B’s help to me here, as he sells the competing “EasiForm” for $20US, and Mike I’d happily pay you for that if you want, but at the moment FTG is covering my needs well, and I can see benefit in keeping the form-handling outside of FWPro’s action-based operation. At the least, it’s wiring my brain up to understand the two sides more clearly!

So, if you two can help me understand how to get the field content from my “sort-of-gallery” page into a formfield on the next “place-an-order” page, that would be wonderful!

Many thanks. PHILIP

Philip,

I didn’t see any error on your page to be honest, what I seen was the value not getting passed on and I think the FTG script was added to the first form, but you don’t need it there, just on the second.

If FTG works for you then you do not need to use the PHP easiForm actions, I didn’t mention that you did. :slight_smile:

From what I could see your values from the first form (email field form) where not getting passed to the second form (FTG form), I suspect that was because they where not getting picked up there… and there I think * as I mentioned before * that adding the PHP Form Action to your second form that receives the value from the email field on your first form, should sort the problem.

Mike


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

Here you go, this should work, as long as you POST a form to it. Check
your Form Setup dialog to make sure that it is set to POST and that
the filename of this script is in the Action field.

<?php $name = $_POST['email']; if (trim($name)==' ') { $error = 'Error! No email!'; } // Let's see if we have an error if ($error) { echo $error; } else { echo 'Your email address is: ' . $name; } ?>

Walter

On Feb 1, 2009, at 1:32 PM, Philip Caplan wrote:

Firstly, Walter, where you said:

[quote] If you add a closing brace in line 5, your script will work.
[/quote]

I tried what you said and also put in the 2 lines
ini_set(‘display_errors’,1);
error_reporting(E_ALL);
but I’m still not getting a result. Could you kindly post here the
complete correct text, perhaps I’ve put the missing } in the wrong
place!


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

What I would do is make checkboxes for each picture (that way people
can buy more than one thing).

So on your gallery page, you would have a checkbox under each picture.
This checkbox would be named for the item it refers to, so let’s say
you had pictures of Stooges for sale, you would have a checkbox named
larry, another named curly, and another named moe. If someone is
seriously into their Stooges, then when this form was posted to the
next page – the one with the send us your money stuff on it – then
it would arrive looking like this:

Array(
	larry => '1',
	curly => '1',
	moe => '1',
	submit => 'Submit'
)

If they only wanted one Stooge, then the array would only have one
element and the Submit button. Checkboxes will be sent by the browser
if they are checked, and they don’t get sent if they are not checked.

So let’s say then that your order page had fields for name, address,
credit card, and whatnot. You would simply also add a hidden field for
each Stooge to that form page. Apply the PHP Form Action to that page,
and you would be all set. Now, no matter how you process the form from
that point on, any purchases from the gallery page would be reflected
in the form that gets sent from the order page, because the Action
would “wire” those hidden form fields to have the same value as the
fields on the previous page. Imagine it as a sort of bucket brigade,
passing the output of the first page on to the third.

If you wanted to be more flexible about how many products you had to
offer, and didn’t want to have to constantly update the order form
page to have a hidden field for each item in your gallery, then you
could name all of the checkboxes on the gallery in this manner:

items['larry']
items['curly']
items['moe']

Then, on your order page, you would simply have a single hidden field
named ‘orders’. The first page would post an array containing the
images that were checked off, and the second page would send that
array along to the form processor. If you wanted to be really fancy,
you would calculate the price by checking the size of that array:

$total = round((count($_POST['items']) * 9.95), 2);

Back in your final form handler, you would parse out which pictures
were ordered by looking into that items array. So if they had ordered
Larry and Moe, the items form field would contain:

Array(
	larry => 1,
	moe => 1
)
//and you could make it a readable string thusly:
$order = implode(', ',array_keys($_POST['orders']));
//which outputs 'larry, moe'

I know I’ve dumped a bunch of stuff on you all at once, but this is a
pretty accessible thing to try out as a beginner to PHP. I recommend
you try to stumble through it, and see where you get. Post questions
(and preferably links to broken pages if you’re stuck) so we can pitch
in and help you get up that first rung of the ladder.

Walter

On Feb 1, 2009, at 1:32 PM, Philip Caplan wrote:

So, if you two can help me understand how to get the field content
from my “sort-of-gallery” page into a formfield on the next “place-
an-order” page, that would be wonderful!


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

On 1 Feb 2009, 11:29 pm, waltd wrote:

Here you go, this should work, as long as you POST a form to it. Check
your Form Setup dialog to make sure that it is set to POST and that
the filename of this script is in the Action field.

$name = $_POST[‘email’];
if (trim($name)==’ ') {
$error = ‘Error! No email!’;
}
// Let’s see if we have an error
if ($error) {
echo $error;
} else {
echo 'Your email address is: ’ . $name;
}
?>

Walter

Hi Walter. In the 5th message of this thread, I said that what I was doing was putting this into a Markup item on the page, and asked if I had got “the correct idea”.

I see that you say “[make sure] that the filename of this script is in the Action field.” What??? A script with a name?

So this PHP code won’t work if it’s in a Markup item on the page? It’s meant to be external to the page?

PHILIP


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

Philip, the filename that needs to be in the action field is the name of the file/script the form is sent to, when you press ‘Submit’ the form needs to be sent somewhere, this ‘somewhere’ is the filename ‘value’ of the action field under the ‘Form Setup…’ settings for that form, this could be ‘myotherpage.php’ for example.

Yes it will work in a page mark-up item, this code makes sense to keep on the page and not in an external file.

Actually I see this code above is using $_POST[] to pull the values from the page before so the PHP Form action is not needed on that page, just remember the field on the page before needs to be given a name of ‘name’ (without quotes) for the name value to be echoed out… I know you are only testing if you can get this working and I think used some principals from the examples but really it helps to call the form elements and php values something that make sense, for example, you are passing on the value of email but the variable name you are using has been swapped to name, it would make more sense calling the email field ‘email’ and then picking up the value at the second form with $email = $_POST[‘email’];, so each instance of $name would be changed to $email , doing this just makes things easier to read and so keep confusion to a minimum.

HTH


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

Mike, thanks for that, the penny is beginning to drop. :slight_smile:

The script (as a Markup item) sort of works now that I’ve changed the page it is on so it ends “.php” instead of “.html”

Am I correct in thinking that a page ending “.php” which contains only valid HTML will render the same in all browsers as if it had ended “.html” ? The only difference is that anything between <?PHP and ?> gets evaluated and the result inserted if the file ends “.php”.

Now, back to my comment “sort of works” above. It generates the text “Your email address is:” but doesn’t put a value after it! Your last message implies that by having a field in the previous page called ‘email’ will make it not work, but doesn’t the PHP code say:

$name = $_POST[‘email’];
(meaning: put into a variable called name the value passed in ‘email’)

and since the Error variable is not being shown, shouldn’t the content of $name be shown?

If I had used $sentEmail (or any other valid variable-name) instead of both occurrences of $name wouldn’t that be equally OK?

Still trying to learn! :slight_smile:


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

This will work, as long as you put it in a page called something.php
and then adjust your form to point to that page. Whether you use a
text editor or Freeway to build that page is immaterial.

Walter

On Feb 2, 2009, at 4:30 AM, Philip Caplan wrote:

So this PHP code won’t work if it’s in a Markup item on the page?
It’s meant to be external to the page?


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