Help In multiple if else

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
talat50
Forum Newbie
Posts: 1
Joined: Thu Sep 30, 2010 8:38 am

Help In multiple if else

Post by talat50 »

Hello frnds i am using mutiple and conditions in if.but i am having problem.i have in adminaproval variable=0;but it doesnt chek its condition.its still goes to last if else.which has adminapproval=1;


<?php
include('../../includes/DB.class.php');
$name = $_POST['txt_name'];
$password = $_POST['txt_password'];
//echo "$name";
//echo "$password";
//getch();
//public function user_Exist($name,$pswd){
require('Login_DAO.class.php');
$login_dao=new LoginDAO();
$returnarray=$login_dao -> user_Exist($name,$password);
$i=$returnarray[0];
$usertype=$returnarray[1];
$adminApproval=$returnarray[2];

echo "usertype=$usertype \t";
echo "adminApproval=$adminApproval\t";

if($i == 0)
{

$_SESSION['msg'] = "Wrong Username or &nbsp;Password";
getch();
header("Location:../index.php");
}
else if($i == 1 && $usertype == 'Admin')
{
session_start();
$sessionid=session_id();
echo "$sessionid";
//$maxRegId = mysql_fetch_array($result);
$_SESSION['id'] = $sessionid;
header("Location:../../../../in-admin-panel/index.php");
}

else if($i == 1 && ( $adminApproval='0' && $usertype == 'Seller'))
{
echo "Wait For Admin Aproval";
getch();
}
else if($i == 1 && ($usertype == 'Seller' && $adminApproval='1'))

{

session_start();
$sessionid=session_id();
echo "$sessionid";

getch();
header("Location:../../Seller/myshop.php");

}

//}
//}
?>



////////////////////////////////////////////////////////////////////
OutPut

usertype=Seller adminApproval=0 6t50e31cf3em7l8np4cth47791
Fatal error: Call to undefined function getch() in C:\wamp\www\architecturedataforebazaradminviewscreenshot\Final_EBazar\Final_EBazar\admin\classes\Login_BL.class.php on line 70

its going on 4th else if.it should be in 3rd.
Help me.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Help In multiple if else

Post by Celauran »

Code: Select all

else if($i == 1 && ( $adminApproval='0' && $usertype == 'Seller'))
else if($i == 1 && ($usertype == 'Seller' && $adminApproval='1'))
You're using assignment operators instead of comparison operators.
Post Reply