标题位置不起作用但卡在页面中

时间:2013-07-30 09:50:15

标签: php header location

所以我有一个按钮

<input type="button" value="add" onclick="document.location.href='add.php?myUcode=<?=$row['ucode'];?>'" />

到另一个页面(让我们称之为Page1)。在Page1中,我想为$ _SESSION ['employees']添加一个值,然后将其重定向回home.php。但是当我点击按钮时,它会卡在add.php中。在调用Header方法之前没有回显或空格。现在我不知道我的代码有什么问题:

<?php
session_start();
if ($_POST['tambah_ucode']) {
if (isset($_SESSION['jum_petugas'])) {
    $_SESSION['jum_petugas'] = 1;
    $ctr = $_SESSION['jum_petugas'];
} else {
    $ctr = $_SESSION['jum_petugas'];
    $ctr++;
    $_SESSION['jum_petugas'] = $ctr;
}
$_SESSION['ucode_petugas'][$ctr] = $_POST['tambah_ucode'];
header('Location: localhost/hrm2.1/lembur_add.php');
}
?>

4 个答案:

答案 0 :(得分:0)

试试这个,

header('Location: lembur_add.php');
exit;

header('Location: http://localhost/hrm2.1/lembur_add.php');
exit;

答案 1 :(得分:0)

header('location:localhost/hrm2.1/lembur_add.php')

没有空间

答案 2 :(得分:0)

尝试以下

header('Location:http://localhost/hrm2.1/lembur_add.php');

答案 3 :(得分:0)

而不是标题(...),请尝试

echo "<script type='text/javascript'> document.location = 'yourLocation'; </script>";