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 .
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
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; ?>
.
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!
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 .
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;
}
?>
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.
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?
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 😉
like this?I get http://www.thinkmktg.com/index.php/Request-for-Proposal/Thank-You/ the line array( ) comes up<?php print_r($_POST); ?>
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.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.