Chris Val Kef Posted April 10, 2006 Share Posted April 10, 2006 I got a form to select the level of user to login in the system. Part of this code is: <td height=10><select name="user"> <option value=0 selected> Student</option> <option value=1> Tutor </option> </select> </td>In php file i use if-else to check the type of user trying to login in order to do the right mysql_db_query in students or tutors table.Part of code is:if ( '".$_POST["user"]."' == 1 ) --> for tutors{ .......}else if ( '".$_POST["user"]."' == 0 ) -->for students{ ......}The problem is that php checks only if user is student, whether i select in the form tutor or student.If the user and password are correct it returns the student pages, whether i selected tutor or student.It's just looking in the student table.I've tried some things and when in the IF-ELSE i changed 0 and 1 for student and tutori noticed that php then looks only in tutors table.I think i'm doing something wrong with the <SELECT name=...>, <OPTION value=...> and IF-ELSE...Got any ideas???Thank you all in advance! Quote Link to comment https://forums.phpfreaks.com/topic/7011-php-form-handling-problem/ Share on other sites More sharing options...
wildteen88 Posted April 10, 2006 Share Posted April 10, 2006 Your if/elseif statment is a little wrong it should be this:[code]if ($_POST['user'] == 1 ) {}else if ($_POST['user'] == "student" ){}[/code]What is the code you use for your [i]<SELECT name=...>, <OPTION value=...>[/i]? It show be something like this:[code]<select name="user"> <option value="student">Student</option> <option value="tutor">Tutor</option></select>[/code]Then your if/elseif statment should look like this:[code]if ($_POST['user'] == "student" ) { //code for student}else if ($_POST['user'] == "tutor" ){ //code for tutor}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/7011-php-form-handling-problem/#findComment-25461 Share on other sites More sharing options...
Chris Val Kef Posted April 10, 2006 Author Share Posted April 10, 2006 THANK YOU!!!It finally works... I've tried before what you told me but my mistake was in the if-else statements.I was using '".$_POST["..."]."'.... I am a newbie...THANX again! Quote Link to comment https://forums.phpfreaks.com/topic/7011-php-form-handling-problem/#findComment-25622 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.