public function updateprofile() { $upload_gambar = Photo::recordImage(); $input = array('default_photo_id' => is_numeric($upload_gambar) ? $upload_gambar : 'NULL', 'firstname' => Input::get('firstname'), 'lastname' => Input::get('lastname'), 'email' => Input::get('email'), 'phone_number' => Input::get('phone'), 'slug' => Input::get('url'), 'city_id' => (int) Input::get('city_id'), 'birthday' => mktime(0, 0, 0, (int) Input::get('month'), (int) Input::get('date'), (int) Input::get('year')), 'description' => Input::get('description')); $update = User::updateprofile($input); if ($update == 'ok') { Session::flash('success', 'Edit profile is successfull'); return Redirect::route('edit_profile'); } elseif ($update == 'no') { Session::flash('failed', 'Edit profile is failed'); return Redirect::route('edit_profile'); } else { Session::flash('validation', $update); return Redirect::route('edit_profile'); } }
} if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) { header("Access-Control-Allow-Headers: \n\t\t\t{$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}"); } exit(0); } include_once 'classes/user.class.php'; $ObjUser = new User(); //http://stackoverflow.com/questions/15485354/angular-http-post-to-php-and-undefined $postdata = file_get_contents("php://input"); $response = array(); if (isset($postdata)) { $request = json_decode($postdata); $id = $request->id; $first_name = $request->first_name; $last_name = $request->last_name; $birth = $request->birth; $gender = $request->gender; $who_can = $request->who_can; $current_password = $request->current_password; if ($request->new_password) { $new_password = $request->new_password; } else { $new_password = ''; } $mensaje = $ObjUser->updateprofile($id, $birth, $birth, $current_password, $new_password, $first_name, $last_name, $gender, $who_can); $response = array('success' => true, 'message' => $mensaje); } else { $response = array('success' => false, 'message' => "Not called properly with username parameter!"); } echo json_encode($response);