Forums

dynamically show/ hide forms using php

mypethamster 07 Dec, 2009
Ok!, i have a problem with the redirect, as when using this plugin, it uses GET instead of POST, which of course means values are display within the web address, when directed to payment site.

Now! I know you are not supposed to enter <form> etc tags inside 'Form Code' code boxes, BUT!

Using PHP, can you control, if or when, the form content is displayed depending on a value posted to the form page. Then using PHP, could i insert a second form to show in its place?

example rough:
<?php
if($_POST["showform"]==1)
{
?>
form 1 code......

<?php
}
else
{
echo "</form>"; //closing tag to take place of chornoform closing form tag
echo "<form action=\"paymentsite.com\" method=\"post\">";
//rest of code to process payment
}
//no closing tag as chornoform closing form tag will be used
?>

will this work? or will this cause problems within chronoform app.
GreyHead 07 Dec, 2009
Hi MyPetHampster,

I'm really not sure what you are trying to achieve here. I think that the two forms would probably show but you'd have no data in the second one.

You might be better using a multi-page form and putting the optional payment codes into the second step so that would show different inputs depending on the payment mode selected, then use cURL after submission.

Bob

PS I'm not sure why this is in an new thread - should I merge them??
nml375 07 Dec, 2009
Hi MyPetHampster,
You can indeed create a second form after the first one, by closing the first one and adding a second form tag (I've done that on one occasion when I implemented a background upload form). One word of caution however, CF uses Joomla's security token feature, which will be inserted after the Form HTML code is executed. As such, the actual security token will be injected in the second form, making the first form "unsubmittable" if the TokenCheck feature is enabled. This also means that you get an additonal hidden form input in your second form which is pretty much beyond your control.
You can work around this using some creative javascripting, though this will only work if your visitors have JS enabled..

The multipage plugin, as suggested by Bob, would probably be a better approach for this.

/Fredrik
mypethamster 07 Dec, 2009
javascript not an option, they would remove my exercise wheel, and you know how hamsters (not hampster, by the way) love their wheels LOL.
This topic is locked and no more replies can be posted.