I am working on a project in php, but I am stuck. I have a login form with 3 checkboxes and 2 text fields for username and password. Each checkbox represents a user, such as admin, student and lecturer. So when a user wants to login, he has to provide his username, password and check one of the checkboxes. So if the user is stored in the database as a student, he has to check the student checkbox and press the submit button. Then while processing, the system will check if this user is stored as student. If that is the case he can now login. Otherwise the login form comes back.
I have an array of checkboxes:
<Input type = "checkbox" name=" cool[] "value= "student">
<Input type = "checkbox" name=" cool[]" value=" admin">
<Input type = "checkbox" name=" cool[]" value=" lecturer">
<Input type = "submit" name= "submit" value= "login">
In the php part I have:
If (isset($_POST['submit'] ){
$user=$_POST['textfield_value_username'] ;
$pass=$_POST['textfield_value_passeord'] ;
$check=$_POST['cool'] ;
foreach ($check as $kio) {
$d= "select * from table-name
where = $user = 'value_from _db' , "
$pass= 'value_from_db' and $kio='value_in-db';
if($d) {
// do something...
}
}
}
This is an overview of the code. When I try it it doesn't work, but when I do select *
and I use only $user
and $pass
it works. When I use only select * .... Where ... $Kio ..
it works also. But when I combine all, it doesn't work and it doesn't give any error.
So, I don't know if I was clear, but this is all about the problem I have. I have been searching on internet but I got no result.