<?xml version="1.0"?><!-- generator="bbPress" -->

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>

<channel>
<title>MachForm Community Forums Topic: How can I set PHP variables in forms?</title>
<link>https://www.machform.com/forums/</link>
<description>MachForm Community Forums Topic: How can I set PHP variables in forms?</description>
<language>en</language>
<pubDate>Sat, 07 Nov 2026 09:15:58 +0000</pubDate>

<item>
<title>nilsmierzynski on "How can I set PHP variables in forms?"</title>
<link>https://www.machform.com/forums/topic/how-can-i-set-php-variables-in-forms#post-3973</link>
<pubDate>Fri, 12 Dec 2008 00:29:52 +0000</pubDate>
<dc:creator>nilsmierzynski</dc:creator>
<guid isPermaLink="false">3973@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Phantastic! Works great!&#60;br /&#62;
Thank you very much!&#60;/p&#62;
&#60;p&#62;Happy Holidays.&#60;br /&#62;
Nils
&#60;/p&#62;</description>
</item>
<item>
<title>redityo on "How can I set PHP variables in forms?"</title>
<link>https://www.machform.com/forums/topic/how-can-i-set-php-variables-in-forms#post-3963</link>
<pubDate>Thu, 11 Dec 2008 08:51:44 +0000</pubDate>
<dc:creator>redityo</dc:creator>
<guid isPermaLink="false">3963@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Hi Nils,&#60;/p&#62;
&#60;p&#62;Sorry for the delays, I think I give you wrong instruction, it's my bad!. it's not to replace but it suppose to add the code.&#60;br /&#62;
However, you want to select the &#34;drop down&#34; field based on &#34;select&#34; ID, let say you have this url : &#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://www.hoeffner.de/machform/embed.php?id=2&#38;#38;element_17=2&#34; rel=&#34;nofollow&#34;&#62;http://www.hoeffner.de/machform/embed.php?id=2&#38;#38;element_17=2&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;You already see this code around line 637:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;$option_markup .= &#38;quot;&#38;lt;option value=\&#38;quot;{$option-&#38;gt;id}\&#38;quot; {$selected}&#38;gt;{$option-&#38;gt;option}&#38;lt;/option&#38;gt;\n&#38;quot;;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;please add these code exactly above that line :&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;if ((trim($_GET[&#38;#39;element_17&#38;#39;]) == $option-&#38;gt;id) &#38;#38;&#38;#38; ($element-&#38;gt;id == &#38;#39;17&#38;#39;) &#38;#38;&#38;#38; ($_GET[&#38;#39;id&#38;#39;] == &#38;#39;2&#38;#39;)) {
	$selected = &#38;#39;selected=&#38;quot;selected&#38;quot;&#38;#39;;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;it should select &#34;Berlin-Marzahn&#34; ...
&#60;/p&#62;</description>
</item>
<item>
<title>yuniar on "How can I set PHP variables in forms?"</title>
<link>https://www.machform.com/forums/topic/how-can-i-set-php-variables-in-forms#post-3959</link>
<pubDate>Wed, 10 Dec 2008 20:16:15 +0000</pubDate>
<dc:creator>yuniar</dc:creator>
<guid isPermaLink="false">3959@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Oops..sorry. It seems your post was buried. I've notified redityo.&#60;br /&#62;
He should reply soon with some solution.
&#60;/p&#62;</description>
</item>
<item>
<title>nilsmierzynski on "How can I set PHP variables in forms?"</title>
<link>https://www.machform.com/forums/topic/how-can-i-set-php-variables-in-forms#post-3956</link>
<pubDate>Wed, 10 Dec 2008 15:49:15 +0000</pubDate>
<dc:creator>nilsmierzynski</dc:creator>
<guid isPermaLink="false">3956@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Did you forget to answer my post?&#60;br /&#62;
Please give me your advice. &#60;/p&#62;
&#60;p&#62;Thank you.&#60;br /&#62;
Nils
&#60;/p&#62;</description>
</item>
<item>
<title>nilsmierzynski on "How can I set PHP variables in forms?"</title>
<link>https://www.machform.com/forums/topic/how-can-i-set-php-variables-in-forms#post-3899</link>
<pubDate>Thu, 04 Dec 2008 22:25:39 +0000</pubDate>
<dc:creator>nilsmierzynski</dc:creator>
<guid isPermaLink="false">3899@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Hi redityo!&#60;/p&#62;
&#60;p&#62;Sorry for the delay...&#60;br /&#62;
Here is the form URL: &#60;a href=&#34;http://www.&#34; rel=&#34;nofollow&#34;&#62;http://www.&#60;/a&#62; h o e f f n e r .de/machform/embed.php?id=2&#60;/p&#62;
&#60;p&#62;I want to set one of this options &#34;selected&#34; via PHP variable in this drop-down selection:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;select name=&#38;quot;element_17&#38;quot; id=&#38;quot;element_17&#38;quot; class=&#38;quot;element select large&#38;quot;&#38;gt;
&#38;lt;option selected=&#38;quot;selected&#38;quot; value=&#38;quot;&#38;quot;/&#38;gt;
&#38;lt;option value=&#38;quot;2&#38;quot;&#38;gt;Berlin-Marzahn&#38;lt;/option&#38;gt;
&#38;lt;option value=&#38;quot;3&#38;quot;&#38;gt;Berlin-Waltersdorf (Schönefeld)&#38;lt;/option&#38;gt;
&#38;lt;option value=&#38;quot;4&#38;quot;&#38;gt;Berlin-Wedding Pankstraße (Mitte)&#38;lt;/option&#38;gt;
&#38;lt;option value=&#38;quot;5&#38;quot;&#38;gt;Chemnitz-Röhrsdorf&#38;lt;/option&#38;gt;
&#38;lt;option value=&#38;quot;6&#38;quot;&#38;gt;Cottbus-Willmersdorf&#38;lt;/option&#38;gt;
&#38;lt;option value=&#38;quot;7&#38;quot;&#38;gt;Dresden-Altfranken&#38;lt;/option&#38;gt;
&#38;lt;option value=&#38;quot;8&#38;quot;&#38;gt;Dresden-Elbepark&#38;lt;/option&#38;gt;
&#38;lt;option value=&#38;quot;9&#38;quot;&#38;gt;Erfurt-Waltersleben&#38;lt;/option&#38;gt;
&#38;lt;option value=&#38;quot;10&#38;quot;&#38;gt;Frankfurt-Gründau&#38;lt;/option&#38;gt;
&#38;lt;option value=&#38;quot;11&#38;quot;&#38;gt;Fürth&#38;lt;/option&#38;gt;
&#38;lt;option value=&#38;quot;12&#38;quot;&#38;gt;Halle-Peißen&#38;lt;/option&#38;gt;
&#38;lt;option value=&#38;quot;21&#38;quot;&#38;gt;Hamburg-Barsbüttel&#38;lt;/option&#38;gt;
&#38;lt;option value=&#38;quot;13&#38;quot;&#38;gt;Leipzig-Günthersdorf&#38;lt;/option&#38;gt;
&#38;lt;option value=&#38;quot;14&#38;quot;&#38;gt;Leipzig-Taucha&#38;lt;/option&#38;gt;
&#38;lt;option value=&#38;quot;15&#38;quot;&#38;gt;Magdeburg-Langenweddingen&#38;lt;/option&#38;gt;
&#38;lt;option value=&#38;quot;16&#38;quot;&#38;gt;Magdeburg-Pfahlberg&#38;lt;/option&#38;gt;
&#38;lt;option value=&#38;quot;17&#38;quot;&#38;gt;Mannheim-Schwetzingen&#38;lt;/option&#38;gt;
&#38;lt;option value=&#38;quot;18&#38;quot;&#38;gt;München-Freiham&#38;lt;/option&#38;gt;
&#38;lt;option value=&#38;quot;19&#38;quot;&#38;gt;Rostock-Bentwisch&#38;lt;/option&#38;gt;
&#38;lt;/select&#38;gt;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Hope that will help you to advice me.&#60;br /&#62;
Thank you, Nils
&#60;/p&#62;</description>
</item>
<item>
<title>redityo on "How can I set PHP variables in forms?"</title>
<link>https://www.machform.com/forums/topic/how-can-i-set-php-variables-in-forms#post-3876</link>
<pubDate>Tue, 02 Dec 2008 08:53:33 +0000</pubDate>
<dc:creator>redityo</dc:creator>
<guid isPermaLink="false">3876@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Hi nils,&#60;/p&#62;
&#60;p&#62;what is your drop down value ? however could I have your form URL ?
&#60;/p&#62;</description>
</item>
<item>
<title>nilsmierzynski on "How can I set PHP variables in forms?"</title>
<link>https://www.machform.com/forums/topic/how-can-i-set-php-variables-in-forms#post-3875</link>
<pubDate>Mon, 01 Dec 2008 21:34:13 +0000</pubDate>
<dc:creator>nilsmierzynski</dc:creator>
<guid isPermaLink="false">3875@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Hi redityo!&#60;/p&#62;
&#60;p&#62;Sorry... no it did not wor here...&#60;/p&#62;
&#60;p&#62;when I open the form (which is actually an iframe of another page) directly like:&#60;br /&#62;
/machform/view.php?id=2&#38;#38;element_17=10&#60;/p&#62;
&#60;p&#62;there are no options available in the drop-down element.&#60;/p&#62;
&#60;p&#62;Something must still be wrong.&#60;br /&#62;
Thank you for your effort and brilliant support.&#60;br /&#62;
Best wishes, Nils
&#60;/p&#62;</description>
</item>
<item>
<title>redityo on "How can I set PHP variables in forms?"</title>
<link>https://www.machform.com/forums/topic/how-can-i-set-php-variables-in-forms#post-3849</link>
<pubDate>Sat, 29 Nov 2008 12:56:01 +0000</pubDate>
<dc:creator>redityo</dc:creator>
<guid isPermaLink="false">3849@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Hi Nils,&#60;/p&#62;
&#60;p&#62;Try with this one &#60;/p&#62;
&#60;pre&#62;&#60;code&#62;if ((trim($_GET[&#38;#39;element_17&#38;#39;]) == $option-&#38;gt;option) &#38;#38;&#38;#38;
($element-&#38;gt;id == &#38;#39;17&#38;#39;) &#38;#38;&#38;#38;
($_GET[&#38;#39;id&#38;#39;] == &#38;#39;2&#38;#39;)) {
	$selected = &#38;#39;selected=&#38;quot;selected&#38;quot;&#38;#39;;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;I see that you wrong put the condition it should $element-&#38;gt;id == '17' not $element-&#38;gt;id == 'element_17'
&#60;/p&#62;</description>
</item>
<item>
<title>nilsmierzynski on "How can I set PHP variables in forms?"</title>
<link>https://www.machform.com/forums/topic/how-can-i-set-php-variables-in-forms#post-3832</link>
<pubDate>Thu, 27 Nov 2008 17:37:55 +0000</pubDate>
<dc:creator>nilsmierzynski</dc:creator>
<guid isPermaLink="false">3832@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Hi redityo!&#60;/p&#62;
&#60;p&#62;Sorry I was a bit imprecise in this point:&#60;/p&#62;
&#60;p&#62;The iframe-form should been loaded with this url (on my opinion?!?):&#60;br /&#62;
/machform/view.php?id=2&#38;#38;element_17=10&#60;/p&#62;
&#60;p&#62;form id=2&#60;br /&#62;
drop-down select id=element_17&#60;br /&#62;
drop-down select value= 10 (for example)&#60;/p&#62;
&#60;p&#62;Because I do not have the variable &#34;city&#34; I changed it to this,&#60;br /&#62;
but without success! The result was that no option were displayed.&#60;br /&#62;
I must be wrong somewhere...&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;if ((trim($_GET[&#38;#39;element_17&#38;#39;]) == $option-&#38;gt;option) &#38;#38;&#38;#38; ($element-&#38;gt;id == &#38;#39;element_17&#38;#39;) &#38;#38;&#38;#38; ($_GET[&#38;#39;id&#38;#39;] == &#38;#39;2&#38;#39;)) {
	$selected = &#38;#39;selected=&#38;quot;selected&#38;quot;&#38;#39;;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Hope you can help me with that...&#60;br /&#62;
Thank you!&#60;br /&#62;
Nils
&#60;/p&#62;</description>
</item>
<item>
<title>redityo on "How can I set PHP variables in forms?"</title>
<link>https://www.machform.com/forums/topic/how-can-i-set-php-variables-in-forms#post-3704</link>
<pubDate>Mon, 17 Nov 2008 19:10:25 +0000</pubDate>
<dc:creator>redityo</dc:creator>
<guid isPermaLink="false">3704@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Hi,&#60;/p&#62;
&#60;p&#62;What for form.php is ? do you embed machform code to &#34;form.php&#34; ?&#60;br /&#62;
however you need to edit &#34;view-functions.php&#34;, Let say you have form with id = '1' and drop down with element id = '2'. For example drop down values are :&#60;/p&#62;
&#60;p&#62;-one&#60;br /&#62;
-two&#60;br /&#62;
-three&#60;/p&#62;
&#60;p&#62;around line 637 you will find :&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;$option_markup .= &#38;quot;&#38;lt;option value=\&#38;quot;{$option-&#38;gt;id}\&#38;quot; {$selected}&#38;gt;{$option-&#38;gt;option}&#38;lt;/option&#38;gt;\n&#38;quot;;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;try to replace with&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;if ((trim($_GET[&#38;#39;city&#38;#39;]) == $option-&#38;gt;option) &#38;#38;&#38;#38; ($element-&#38;gt;id == &#38;#39;2&#38;#39;) &#38;#38;&#38;#38;
($_GET[&#38;#39;id&#38;#39;] == &#38;#39;1&#38;#39;)) {
   $selected = &#38;#39;selected=&#38;quot;selected&#38;quot;&#38;#39;;
}&#60;/code&#62;&#60;/pre&#62;</description>
</item>
<item>
<title>nilsmierzynski on "How can I set PHP variables in forms?"</title>
<link>https://www.machform.com/forums/topic/how-can-i-set-php-variables-in-forms#post-3692</link>
<pubDate>Mon, 17 Nov 2008 15:47:44 +0000</pubDate>
<dc:creator>nilsmierzynski</dc:creator>
<guid isPermaLink="false">3692@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;I would love to load the form with different option selection depending from where I open the form. For example:&#60;/p&#62;
&#60;p&#62;berlin.php with link to form.php?id=1&#38;#38;city=berlin ===&#38;gt; form.php: &#38;lt;SELECT&#38;gt;&#38;lt;OPTION value=&#34;Berlin&#34; selected&#38;gt;&#60;/p&#62;
&#60;p&#62;I know the PHP code, but I am not sure where I have to place the code to get it just in the form (ID) I want it to be.&#60;/p&#62;
&#60;p&#62;Thank you all&#60;br /&#62;
Nils
&#60;/p&#62;</description>
</item>

</channel>
</rss>
