We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

freeform module?

Development and Programming

josephvv's avatar
josephvv
23 posts
17 years ago
josephvv's avatar josephvv

How Do I post data to another page? IE, I have a form that I want to the results of to show in a Thank You Page. Ive looked at http://www.solspace.com/docs/entry/freeform_26_entries_tag/ but I’m still not sure which line of code will do this?

thanks!

       
Bruce2005's avatar
Bruce2005
536 posts
17 years ago
Bruce2005's avatar Bruce2005

Passing form values in php is easy enough, one way is: Form example:

<form action="/index.php/journal/bad-words/" method=post> 
My name is:<input type="text" id="YourName" name="YourName"> 
My favorite bad word is: 
<input type="text" id="FavoriteWord" name="FavoriteWord"> 


<input type="submit" name="submit" value="Send">

</form>

Next page -
<?php
$YourName = $_POST['YourName'];
$FavoriteWord = $_POST['FavoriteWord'];
?>
Hi <?php print $YourName; ?>
You like the word <b> <?php print $FavoriteWord; ?> !?! </b>

example .

       
josephvv's avatar
josephvv
23 posts
17 years ago
josephvv's avatar josephvv

Thanks, I will give that a try!

       
josephvv's avatar
josephvv
23 posts
17 years ago
josephvv's avatar josephvv

Ok, using the free form code below

//////

{exp:freeform:form form_name="rfp" required="first_name|email" notify="[email protected],[email protected]" template="rfp" return="Marketing-Quiz/Thank-You"} First Name

<input type=”text” name=”first_name” value=”” />

{/exp:freeform:form}

//////

How Do I write it in there to pass the info?

Thanks!

-j

       
Bruce2005's avatar
Bruce2005
536 posts
17 years ago
Bruce2005's avatar Bruce2005
return="Marketing-Quiz/Thank-You</code></pre>

Add the php to that template and enable php in template preferences. You may have to add 
id-"first_name"  to the input tag. The above is how I pass values, I haven't used it with freeform but it should work...see the first form example, the only thing in the input extra is id= which seems to be needed to not get an error, at least on mine.

<pre><code><?php 
$name = $_POST['first_name'];
?>
Hi <?php print $name; ?>

.

       
josephvv's avatar
josephvv
23 posts
17 years ago
josephvv's avatar josephvv

Thank you for your help! im still having a bit of problem with this.

I have set the prefs to allow PHP and tried the PHP version (without freeform) and worked but I would like to have the freefrom method work. Seems like it should.

So I have this line of code for the acutal form (its truncated)Im using radio buttons so im not sure if thats the problem.

{exp:freeform:form form_name="Marketing_Quiz" notify="[email protected]" template="Marketing_Quiz" return="Request-for-Proposal/Thank-You"} 
  Drive sales and propel business growth 
        <input name="drive_sales_and_propel_business_growth" type="radio" value="yes" class="radio" id="drive_sales_and_propel_business_growth" />
       <strong>Yes</strong>
       <input name="drive_sales_and_propel_business_growth" type="radio" value="no" class="radio" id="drive_sales_and_propel_business_growth" />
       <strong>No</strong>

{/exp:freeform:form}

AND…this in the thank you page…

<?php
$DriveSales = $_POST['drive_sales_and_propel_business_growth'];

?>
Hi <?php print $DriveSales; ?>

Is there something im missing?

thanks alot!

       
Bruce2005's avatar
Bruce2005
536 posts
17 years ago
Bruce2005's avatar Bruce2005

I have similar, not hard to change:

<form method="post" action="/index.php/site/form-values2/">
<input type="radio" name="gender" value="M" />Male  
<input type="radio" name="gender" value="F" />Female  
<input type="radio" name="gender" value="N" />Not Sure
<input type="submit" value="Submit" name="myaction">
</form>

fornm-values3:

<?php
switch($_POST['gender']) {
 case 'M':    //male
echo 'Good Morning Mr';
  break;
  case 'F':    //female
echo 'Good Morning Miss';
  break;
 case 'N': //radio button value for Not Sure.
 //default.
  default:
 echo 'Good Morning';
  break;
  }
?>

example .

       
Brian M.'s avatar
Brian M.
529 posts
17 years ago
Brian M.'s avatar Brian M.

Put this on the thank you page to see if you have any $_POST data coming at all:

print_r($_POST);
       
josephvv's avatar
josephvv
23 posts
17 years ago
josephvv's avatar josephvv

like this?

<?php

print_r($_POST); 

?>

I get http://www.thinkmktg.com/index.php/Request-for-Proposal/Thank-You/ the line array( ) comes up

does that mean it is posting??

I did try this earlier to test and still no luck :(

<?php
switch($_POST['drive_sales_and_propel_business_growth']) {
case 'yes':    //Yes
echo 'YES';  
break;
  }
?>
       
Bruce2005's avatar
Bruce2005
536 posts
17 years ago
Bruce2005's avatar Bruce2005

You have 2 inputs and 2 values though. Cut my 3 to 2

<input name="drive_sales_and_propel_business_growth" 
type="radio" value="yes" class="radio" id="drive_sales_and_propel_business_growth" />
       <strong>Yes</strong>
       <input name="drive_sales_and_propel_business_growth" 
type="radio" value="no" class="radio" id="drive_sales_and_propel_business_growth" />
       <strong>No</strong>
switch($_POST['drive_sales_and_propel_business_growth']) {
case 'yes':    //Yes
echo 'YES';  
break;
case 'no':    //No
echo 'No';  
break;
  }

works in a normal form, if it don’t on yours is freeform prob.

       
josephvv's avatar
josephvv
23 posts
17 years ago
josephvv's avatar josephvv

Right, I see but I still tried the below..to no avail.

<?php
switch($_POST['drive_sales_and_propel_business_growth']) {
case 'yes':    //Yes
echo 'YES';  
break;
  case 'no':    //No
echo 'NO';
  break;
  }
?>
       
Bruce2005's avatar
Bruce2005
536 posts
17 years ago
Bruce2005's avatar Bruce2005

Can be a couple things. Freeform uses entries tag…see Solspace docs, entries tag.

Or it’s stripping out the values going to second page. Are you using the freefoem entries tag in second page?

       
josephvv's avatar
josephvv
23 posts
17 years ago
josephvv's avatar josephvv

I am not using the freeform entries tag on the thankyou page. I should be? I was goin through the doc and I didnt really get it. Im not that verse in programming. Any ideas how I would set up entries on my existing thank you page??

Your help is greatly appreciated!

thanks

       
Bruce2005's avatar
Bruce2005
536 posts
17 years ago
Bruce2005's avatar Bruce2005

Not having tried it, and not seeing anything on solspace forum on passing values, is worth a try. entries tag freeform

{exp:freeform:entries form_name="name of form" orderby="entry_date" sort="asc" limit="1"} 
script may/probably won't not work here. May need field tag?
{/exp:freeform:entries}

I should have thought of that, using freeform is different. dunno if the above will work, going where no man has gone b4 😉

       
Brian M.'s avatar
Brian M.
529 posts
17 years ago
Brian M.'s avatar Brian M.
like this?
<?php

print_r($_POST); 

?>
I get http://www.thinkmktg.com/index.php/Request-for-Proposal/Thank-You/ the line array( ) comes up

If you’re seeing array() come up, then no post information is getting to that page. That array contains all the variables and values that have been POSTed to the page.

In the actual HTML that is generated on the form page, does the form use the POST as its method? And what is listed as the “action”? For your POST data to get to your thank you page, you need to see something like:

<form method="POST" action="/Request-for-Proposal/Thank-You">

If instead you’re seeing action=”” or an action that is different than your thank you page, it won’t work by using POST vars.

What I think is actually happening is that when you actually submit the page, it is calling the same page that submitted the form - this interim page is where Freeform is harvesting its data. Then it redirects to your return page - so technically you’ve gone two pages, not one, and there is now no POST data (because it only lives on the first page you go to). Because of this, no data has been posted.

       
1 2

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.