I have a system for users to apply for driving permit. However, while coding this system, I faced some problem, and the problem I am facing now is that I do not know how can I pass a value from a form from the application pass the processor page ,pass the medical questionnaire page, and lastly to be use in the medical processor page. In my example,
The Overview Layout:
apply2.php > apply_now.php >medical_question.php >medical_question_now.php>success.php
The main question:
What is the best way to transfer a $selectedPermit=$_POST['cat']; value from apply_now.php to medical_question_now.php??
The Explanation:
I have a checkbox form in apply2.php and upon clicking submit, it will link to apply_now.php.
In apply_now.php (php processor page), I was able to retrieve the value selected on the check box and do some processing here. eg. If user have not completed a medical questionnaire in the past 3 years, it will bring them to the medical questionnaire page without inserting any data into the database. If they did the medical questionnaire before then it will go straight to the success page.
In the medical questionnaire, there are 23 questions and each answer will be stored in the database via the medical_questionnair_now.php page.
medical_question_now.php (a php processor page) consists of query to insert the medical questionnaire answers into the database, however, I would like to insert the value that was retrieved from the check box in apply2.php.
Success.php is just a page to tell them congrats.
My current idea:
I think there is 2 way i could bring the data over.
-
Combine apply_now.php with medical_question.php together.
-
Use hidden input which means the processor page must all be expose to the users.
-
After some research, I found out that SESSION can help me achieve it but anyone have any idea how I can use SESSION to do it? (can give me rough explanation for SESSION so I can try it out)
I hope to stick with php for better understanding purpose, but if you guys think there is a better javascript() that can help which is easily understandable, please guide me…I want to learn new things. Thanks
Another Question
Another question I would like to ask is if on my php processor page, I would like to replace the echo with alert(); can i go this:
if($missing1=='1' or $missing2=='1')
{
echo '<script>alert("Sorry. You did have not met the Pre-Requisites for '.$permit .'");</script>';
header ('Location:s_apply2.php');
}
instead of this:
if($missing1=='1' or $missing2=='1')
{
echo"Did not meet pre-requisites for $permit";
}
Thank You so Much for your help…I have learnt alot from here. Thanks Thanks in advance.
Using Session
On another page use:
Javascript question:
Regards