| | |
interesting situation
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2008
Posts: 46
Reputation:
Solved Threads: 0
hey guys... i've encountered something which I think may tax ur brains...
what im trying is this:
There is this coaching institute. A person may come here either as a student to enroll for a course, or as a teacher.
Now, if the person has come as a student, we enter into database DB1, the personal details and the course for which he wishes to enroll.(courses are in a drop down menu)
If the person is for a job, we enter into database DB2, the personal details, and the type of job he is here for.(types of jobs are al;so in a drop down menu).
So basically,
1. the user first enters whether he is a student/teacher. He is then redirected to a page asking for his personal details, and course(for student)/position(for teacher).
2. The data in the 2 cases is inserted into different databases.
the PRoblem
Ir-respective of whether the person is a student/teacher, i want to use a common page to ask for his details. This page, will obviously be connected to a different database based on student/teacher. Also, the drop-down menu on the page will depend on teacher/student.
I am unable to implement this...
somebody help me out...
thx...
cheers...
what im trying is this:
There is this coaching institute. A person may come here either as a student to enroll for a course, or as a teacher.
Now, if the person has come as a student, we enter into database DB1, the personal details and the course for which he wishes to enroll.(courses are in a drop down menu)
If the person is for a job, we enter into database DB2, the personal details, and the type of job he is here for.(types of jobs are al;so in a drop down menu).
So basically,
1. the user first enters whether he is a student/teacher. He is then redirected to a page asking for his personal details, and course(for student)/position(for teacher).
2. The data in the 2 cases is inserted into different databases.
the PRoblem
Ir-respective of whether the person is a student/teacher, i want to use a common page to ask for his details. This page, will obviously be connected to a different database based on student/teacher. Also, the drop-down menu on the page will depend on teacher/student.
I am unable to implement this...
somebody help me out...
thx...
cheers...
Create two forms, one for teacher, and one for student. In both, include the following dropdown menu:
Include this javascript function in the head:
The function will cause the forms to toggle, depending on which option is selected in the dropdown. There are many ways of doing this, but this seems easiest to me.
html Syntax (Toggle Plain Text)
<select onchange="MM_jumpMenu('parent',this,0)"> <option value="">Please select student or teacher..</option> <option value="teacher.php">Teacher</option> <option value="student.php">Student</option> </select>
javascript Syntax (Toggle Plain Text)
<script type="text/javascript"> function MM_jumpMenu(targ,selObj,restore){ //v3.0 eval(targ+".location=\'"+selObj.options[selObj.selectedIndex].value+"\'"); if (restore) selObj.selectedIndex=0; } </script>
Well, you could have the user come to a common page where they select teacher or student. That page could then direct the user to the appropriate form.
A common conceptual error is the idea that php can interact with the browser after the page has been loaded. PHP alone cannot change anything on the users screen after the page is loaded. It takes javascript to modify the users screen after a page loads. Remember, php runs on the server. JavaScript runs on the browser. They can however interact through a xmlhttprequest (AJAX).
A common conceptual error is the idea that php can interact with the browser after the page has been loaded. PHP alone cannot change anything on the users screen after the page is loaded. It takes javascript to modify the users screen after a page loads. Remember, php runs on the server. JavaScript runs on the browser. They can however interact through a xmlhttprequest (AJAX).
•
•
Join Date: Jun 2008
Posts: 46
Reputation:
Solved Threads: 0
•
•
•
•
Well, you could have the user come to a common page where they select teacher or student. That page could then direct the user to the appropriate form.
well, thats exactly what i have done....
what i was looking for was a way to make my code more efficient. It does not matter much in this case as there are only 2 options, but in case there are more, is there a better way to use just the one form where the drop-down menu is variabe??
1. How are you determining whether the user is a student or the teacher ? Do you have a form where the user selects whether he is a student or a teacher ?
2. If you have a dropdown in page1 where the user can select what type of user he is (student or teacher), then you can take respective action in page2 depending upon his choice in page1.
2. If you have a dropdown in page1 where the user can select what type of user he is (student or teacher), then you can take respective action in page2 depending upon his choice in page1.
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Jun 2008
Posts: 46
Reputation:
Solved Threads: 0
•
•
•
•
1. How are you determining whether the user is a student or the teacher ? Do you have a form where the user selects whether he is a student or a teacher ?
2. If you have a dropdown in page1 where the user can select what type of user he is (student or teacher), then you can take respective action in page2 depending upon his choice in page1.
1. Yes. the person first encounters a form (say P1) wherein he has to specify whether he is student/teacher.
2. data form this form is collected in the "action" page (say P2) of P1.
3. What i can do is to use an if-else on P2. If(user)-- show menu 1, else show menu2.
The problem i am facing is--- On P2, the data entered(student/teacher) is retreived using PHP ($_POST[""]).... and the form is built in HTML..... so i end up having HTML code inside my PHP script, which "I think" is the actual source of error .... i dont think we are allowed to usee HTML inside a PHP script....
pls clarify....
thx...
•
•
•
•
The problem i am facing is--- On P2, the data entered(student/teacher) is retreived using PHP ($_POST[""]).... and the form is built in HTML
And, you can have html tags inside php.
php Syntax (Toggle Plain Text)
<?php echo "<html><body>This is just a test!</body></html>"; ?>
php Syntax (Toggle Plain Text)
<?php /* This is test.php */ if(isset($_POST['submit'])) { $selectedvalue = $_POST['type']; if($selectedvalue == "teacher") { echo "Welcome Teacher!"; //do something } else { echo "Welcome Student!"; //do something else } } ?> <html> <body> <form method="post"> Select an option : <select name="type"> <option value='teacher'>Teacher</option> <option value='student'>Student</option> </select><br /> <input type="submit" name="submit" value="submit"> </form> </body> </html>
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
Similar Threads
- Did Hubby Put Spyware on My PC??! (Viruses, Spyware and other Nasties)
- Starting Over (Windows NT / 2000 / XP)
- Security Related Recycle Bin Problem (Windows NT / 2000 / XP)
- Using an entire Hard Drive for Virtual Memory (Motherboards, CPUs and RAM)
- Reply With history ..Hmm..interesting. Lotus Notes problem (Windows NT / 2000 / XP)
- have you ever abused ur powers? (Geeks' Lounge)
- Accelereated Reader (Windows 95 / 98 / Me)
- Mac to PC Network keeps disconnecting (Networking Hardware Configuration)
- Fast data storage (C++)
Other Threads in the PHP Forum
- Previous Thread: Help, Dynamic Subject for mail script
- Next Thread: Array echoing problem
| Thread Tools | Search this Thread |
advanced ajax apache api array basics beginner binary broken cakephp check checkbox class cms code combobox cookies cron curl database date datepart display dynamic echo email error file files folder form forms function functions google head href htaccess html image include includingmysecondfileinthechain insert integration ip java javascript job joomla js limit link login loop mail menu mlm multiple mysql oop parse password paypal pdf php problem procedure query radio random recursion regex remote script search server sessions smarty smash sms soap source space sql stored syntax system table traffic tutorial unicode update upload url validator variable video web xml youtube






