I trying to finish a lessons course for students.
I’m looking for, when a student finish a lesson and push “finish button”, to pass to a PHP global variable scope (likes $L-3, for lesson 3) a value of “1”, and then execute a PHP file where update a database, and after executed this file or “php stack code”, can link back to the index of course page.
After that I can calculate the advance of each student in the course, in the database, for each student and each course.
I didn’t find any button that allow me to pass this value, only have opportunity to link a file where is the database code, that execute correctly, but I don’t find the solution to be back to the index of course page.
I use button group that’s looks nice.
Complete process is : Unit finish > push the button > $L_3=1 > link to a page with code or execute a code file.php > update database and calculate the advance > back to index course page > show the advance.
Someone can help me, giving some advice?
It really depends on how the PHP code file is written. If the PHP code can be written to use GET to receive the variables (most common method), then you pass the variable name and value as part of the link to the PHP code file on the server.
You can do that with any button stack that accepts an html link, like the Button Group does.
The PHP code would then extract that value, update the database and then send them back to the course page. The course page would also likely be a PHP page that pulls the user’s advance from the database and displays it.
thank you for your replay and answer.
I worked on you suggestion and I solve the button link passing information to PHP code, extracting and updating data base. I didn’t find the way to be back at the course_page.php, from the code_file.php, as in your explanation, without put a button for it. I mean put a direct link to course_page.php inside of code.
Thanks a lot, from a rookie.
Glad to hear you’re making progress.
As long as you do not write anything to the document during your PHP code in
code_file.php, you can use the PHP header function to redirect them to any page you want. Where people have issues with doing this is when anything is written to the html body in your PHP code, you can no longer write the header information, so watch for that if you run into issues with the redirect not working.
Thank you very much for your advice.
I find the solution that works with a PHP code:
header('Location: http://www.example.com/course_folder/course_page.php', true, 301);
I’m very thankful for your help.
I will share the result when I finish it.
Is near to works as I like.
I would omit sending the response code, especially a ‘301’. A ‘301’ response code is a permanent redirect and as such it could be cached forever by a caching server. It’s not needed in this scenario.
header('Location: http://www.example.com/course_folder/course_page.php', true);
Thank you for your advice. I made the modification to the code.