Jump to content
Can you dynamically change the HTML code of a page without submitting a form with PHP?
Asked by Alejandro Ramirez
Posted Jun 06 2011 05:48 PM
I am building an online survey using PHP and would like to show each question separately (similar to when you take tests online).
Can I use a single Page with PHP dynamically changing properties and storing answers, or should I create a separate HTML page with a form in each with a submit button on each page?
How do you retain the values across questions without savi to the database until the user reviews all the answers and submits it at the end? (global variables in a single php file -code behind-?
Digital Photography Club
Answered by bogomilshopov
Posted Jun 08 2011 05:16 AM
PHP is a dynamic language - you may create what you want with it. And the answer is yes.
For example if you create a file: poll.php, you can add parameters like this
and to get questions and answers from mySQL database without changing HTML (you will use only one HTML file)
Answered by scrappedcola
Posted Jun 08 2011 07:09 AM
By combining some ajax on your client side with your php on the server side you can accomplish whatever you want. You can also persist your question data either in the server side or client side.
If you wish to persist on the server side set up a second db table to maintain your temporary question answers. Then when the user completes the questionnaire move those temporary answers to the final answers table.The pro's of saving on server side is that the user can leave the questionnaire and come back to finish it later.
Answered by visualAsparagus
Posted Jun 08 2011 11:11 AM
As a follow on to scrappedcola's comment -
I thought I'd mention that you can also save the user's data before submission by using either a cookie or a session on the server.
This may be efficient if you're not storing and analysing the data yourself but sending it on via an API.
I like to call myself a creative realist.
I try to understand relationships, identify issues and create solutions. Bring me an idea and I'll help you make it better, then I'll help you figure out the best way to get it done.
Answered by Alejandro Ramirez
Posted Jun 09 2011 03:31 PM
Scratch that off...
This post has been edited by Alejandro Ramirez: 24 June 2011 - 08:38 AM
Digital Photography Club
Answered by Indianic
Posted Mar 09 2013 01:43 AM
I think you have to go to the best PHP web development company where you get all the answers of your question. I also have so many question but one company IndiaNIC solve it very easily. Their expert PHP developer solve it very easily. I think you have to contact them.