Forums

How to execute php in custom html

eckart 07 Nov, 2020
Hi,

I have the following simple HTML code in a custom html field:
<p>a</p>
<?php echo 'b'; ?>
<p>c</p>

The result is
a

c

So the <?php script is obviously ignored.

What to do?
different_greyhead 08 Nov, 2020
1 Likes
Hi eckart,

Here is how I did it. Make sure you have the Run PHP option set under advanced settings.
eckart 08 Nov, 2020
Hi different_greyhead,

thanks for your answer. Obviously the key ist to set the Run PHP option. However, under Advanced Settings I only have "Locales" and "ACL Profiles", though my chonoforms installation is validated as trial validation. Do I have to activate fully? Or do you have another advice?
NickOg 08 Nov, 2020
Answer
1 Likes
Hi Eckart
You must be looking at Advanced Settings on the form rather than the HTML code block on the Pages.

That is here

rather than here


Nick
eckart 08 Nov, 2020
Hi NickOg,

I got it. Thanks a lot.
adam M 21 Feb, 2021
can I mix php code with html ? like :
<?php 
...
?>

... some html code

if Yes ..then how can I pass variable from php part of the code to the html part ? like :
<?php
$a = 'abc';
?>

<form method="POST" action="https://x.x.x.">
<input name="customerIp" value={str:ip}>
<input name="merchant" value=$a>
<button type="submit" formtarget="_blank">test</button>
</form>
NickOg 21 Feb, 2021
1 Likes
Hi Adam

You should be able to do that.

In the PHP section
$this->set(‘someVariable’,’SomeValue’);

and then access that value in HTML so

<input name="customerIp" value={str:ip}<input name="merchant" value={var: someVariable}>


Nick
adam M 21 Feb, 2021
someVariable ...should be defined somewhere ? as a global variable in CF7 - Settings - Global Vars ?
adam M 21 Feb, 2021
works !
no need to define this variable

Thanks🙂
NickOg 21 Feb, 2021
I guess that I should have added that, if you need it defined to be used from a menu then you will need to pass it as an extra parameter to the form when you could then use (data:someVariable} in the form
Nick
adam M 22 Feb, 2021
OK. so time for second question/problem :
my form has two pages
on page1 there are 2 views :
- first view is a button submit with action to go to the second page of the form
- second view is a html code with a form with submit function ( example in previous posts )

I have a problem : the first view/button is not working ! I can not display the second page. When I remove the second view (html code with form-submit) thes it works .

Why html code prevents from going to the second page ?
NickOg 22 Feb, 2021
Oh! Why do you have an HTML form on the second page? Why not build it directly on that page - adding whatever controls you need there? Or if you really need a separate form you can use the Actions Redirect control to load your form from your first page?
Or have I misunderstood your problem??

Nick
adam M 23 Feb, 2021
HTML is on the first page !

The problem is that on the first page I have 2 views :this html code (with submit action) + a button to go to the second page of the form
This is causing a problem - I can not go to the next page😟

When I set the button properties : type submit - toolbar settings : page/url ... this also is not working - the button is not working - I can not go to any other page😟
When I set the button properties: trype buttn - submit page - second page ..... the same problem😟 it is not working

The only button that is working on the first page and redirecting mi to next page is the button from the html code ( table with submit action ) .
So if a user selects this button from the html code it goes to the submit url , but the user can not choose other option - he is stuck in this page😟
I can not move the user to the next page of my form or to any other url page.

I also found that if I put the html code on the second page of my form - then the form is also not working. I can display the first page of the form but the button submit is not working and I can not go to the second page.

When I remove the view with html code from my form - then the form is working = I can submit first page and go to the second page of the form or go to other url.
When I put back this view with html code ( table action submit ) - the form stops working . It displays only the first page / no way to go to the next.

Hope this will explain my problem.

Why a view with html code is blocking the form ?
You need to login to be able to post a reply.