Check out the LimeSurvey source code on GitHub!

Adding PHP to a Survey

More
4 years 9 months ago #79220 by nathanielelliott
I am looking to add php into the documents that are created in LimeSurvey. For example, adding a simple php statement to "Edit Text Elements" for the opening statement like:
<?php
echo "Hello PHP World";
?>

Every time that I through this into a location, it renders out a commented out php statement. How do I turn this process off?

Please Log in to join the conversation.

More
4 years 9 months ago #79250 by nathanielelliott
Is this possible at all by anyone's knowledge? I can't even find an article about this, thanks!

Please Log in to join the conversation.

More
4 years 9 months ago #79253 by DenisChenu
You want to have php answers ?

Or to use some php script in your surveys ?

You can't have php script in question text. If you want to make some apdatation without changing LS core, You can use some ajax function.



Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).

Please Log in to join the conversation.

More
4 years 9 months ago #79254 by nathanielelliott
My goal is to insert a php script into the beginning / end text areas and some questions. There isn't a way to approve the scripting inside of it instead of LS commenting it out?

Please Log in to join the conversation.

More
4 years 9 months ago - 4 years 9 months ago #79255 by DenisChenu
You can only have javascript.

Use ajax if you really need this.

There isn't a way to approve the scripting inside of it instead of LS commenting it out?

Non, never ....

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
Last Edit: 4 years 9 months ago by DenisChenu.

Please Log in to join the conversation.

More
4 years 9 months ago #79259 by Mazi
Adding PHP code the way you have tried would be a huge security risk. You can only add Javascript to surveys and for security reasons this only works if you turn off the XSS filter, see docs.limesurvey.org/Global+settings&stru...+LimeSurvey#Security

If you want to add a call to a custom PHP script the only solution would be to add an Ajax call using Javascript.


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
4 years 9 months ago #79279 by nathanielelliott
Is there a way then to add a something to the header php file that could simply do a 'include' variable that I can then edit / hardcode into each survey?

Please Log in to join the conversation.

More
4 years 9 months ago #79414 by Mazi
Since the startpage.pstpl also includes the <HEAD> tags, it should be no big deal to add some JS code there to make an Ajax call to a PHP script which can include anything you like.


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
4 years 9 months ago #79514 by DenisChenu

nathanielelliott wrote: Is there a way then to add a something to the header php file that could simply do a 'include' variable that I can then edit / hardcode into each survey?

Hello,

Can use $embedded in config.php.

See config-default.php to see haw to use.

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form