我一直在尝试锻炼为什么登录后无法获取此php代码以将其从index.php重定向到profile.php。
login.php可以正常工作,因为我可以手动进入profile.php,它将被登录。
package com.example.ddursteler1.workouttracker;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import java.util.List;
import java.util.UUID;
public class WorkoutActivity extends SingleFragmentActivity {
public static final String EXTRA_WORKOUT_ID = "com.example.ddursteler1.workouttracker.workout_id";
private static UUID mUUID;
public static Intent newIntent(Context packageContext, UUID workoutId) {
Intent intent = new Intent(packageContext, WorkoutActivity.class);
intent.putExtra(EXTRA_WORKOUT_ID, workoutId);
return intent;
}
@Override
protected Fragment createFragment() {
UUID workoutId = (UUID) getIntent().getSerializableExtra(EXTRA_WORKOUT_ID);
Log.d("createFragment UUID", workoutId.toString());
return WorkoutFragment1.newInstance(workoutId);
}
}
我已经研究过它,并尝试了不同的方式和不同的url,但是到目前为止还没有成功。
任何帮助都会很棒!
答案 0 :(得分:0)
header()函数仅在执行前输出0时才起作用。打印到浏览器的任何内容都将导致“标题已发送”警告,您可以使用元刷新标签甚至JavaScript重定向
<meta http-equiv="refresh" content="5; url=http://example.com/">
5是重定向生效之前的秒数。如果您希望即时输入,请输入0。
或者您可以像这样在JavaScript中进行操作:
// similar behaviour as an HTTP redirect
window.location.replace("http://stackoverflow.com");
// similar behaviour as clicking on a link
window.location.href = "http://stackoverflow.com";
为了使您的PHP header()函数正常工作,请确保之前没有任何输出。您可以打开PHP错误,以查看是否还有其他原因阻止代码执行。
没有确切信息或没有提供您收到的错误消息的更多信息,这是我能给您的最佳答案。请发布更多信息,我会很乐意进行编辑。