i'm watching a tutorials about CMS with OOP - PHP & RainTPL
when i try something like http://localhost/cms/admin/updateuser.php?id=4
it has ID so if(isset($_GET['id']) && (int)$_GET['id']>0) will be executed
but ( else ) executed too because it update the user !!
public function UpdateUser()
{
if(isset($_GET['id']) && (int)$_GET['id']>0)
{
$id = (int)$_GET['id'];
$user = $this->usersModel->GetById($id);
System::Get('tpl')->assign($user);
System::Get('tpl')->draw('updateuser');
}
else
{
if(isset($_POST['UpdateUser']))
{
//Variables
$name = $_POST['name'];
$username = $_POST['username'];
$email = $_POST['email'];
$admin = (int)$_POST['admin'];
$id = (int) $_POST['id'];
//Validation
//array Data
$data = array(
'name' => $name,
'username' => $username,
'email' => $email,
'is_admin' => $admin
);
if($this->usersModel->Update($id,$data))
{
System::Get('tpl')->assign('message','User Updated');
System::Get('tpl')->draw('success');
}
else
{
System::Get('tpl')->assign('message','Error Updating User');
System::Get('tpl')->draw('error');
}
}
else
{
//No Id
System::Get('tpl')->assign('message','NO USER CHOSEN');
System::Get('tpl')->draw('error');
}
}
}
if(isset($_GET['id']) && (int)$_GET['id']>0)
will be executed & else too how in same time !!!!
when i try something like this http://localhost/cms/admin/updateuser.php?id=4
if statement should be executed without else statement because it can Get the id from the url
if(isset($_GET['id']) && (int)$_GET['id']>0)
i need someone explain how does it work ?