Welcome, Guest
Username: Password: Remember me

TOPIC: Adding PHP to a Survey

Adding PHP to a Survey 1 year 11 months ago #79220

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?
The administrator has disabled public write access.

Re: Adding PHP to a Survey 1 year 11 months ago #79250

Is this possible at all by anyone's knowledge? I can't even find an article about this, thanks!
The administrator has disabled public write access.

Re: Adding PHP to a Survey 1 year 11 months ago #79253

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 5845
  • Thank you received: 715
  • Karma: 222
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
The administrator has disabled public write access.

Re: Adding PHP to a Survey 1 year 11 months ago #79254

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?
The administrator has disabled public write access.

Re: Adding PHP to a Survey 1 year 11 months ago #79255

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 5845
  • Thank you received: 715
  • Karma: 222
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 ....
Last Edit: 1 year 11 months ago by DenisChenu.
The administrator has disabled public write access.

Re: Adding PHP to a Survey 1 year 11 months ago #79259

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5279
  • Thank you received: 289
  • Karma: 246
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)limesurvey.org'"
The administrator has disabled public write access.

Re: Adding PHP to a Survey 1 year 11 months ago #79279

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?
The administrator has disabled public write access.

Re: Adding PHP to a Survey 1 year 11 months ago #79414

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5279
  • Thank you received: 289
  • Karma: 246
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)limesurvey.org'"
The administrator has disabled public write access.

Re: Adding PHP to a Survey 1 year 11 months ago #79514

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 5845
  • Thank you received: 715
  • Karma: 222
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
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.160 seconds
Donation Image