PDA

View Full Version : header('LOCATION ???



melissa
پنج شنبه 21 شهریور 1387, 06:28 صبح
سلام
من یه صفحه با php دارم که از دستور header('LOCATION: 2.php برای رفتن (redirect) به یه صفحه دیگه استفاده کردم ، اما یه warning می گیره. کدش به صورت زیره:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="Enstyle.css" type="text/css" media="screen" />
<link rel="stylesheet" href="ygma.css" type="text/css" media="screen" />
<link rel="stylesheet" href="Sts.css" type="text/css" media="screen" />
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style13 {color: #B3D1FC}
body {
background-color: #D4DBE5;
}
--></style></head>
<?php
header('LOCATION: 2.php');
?><body></body>

و خطا هم :
Warning: Cannot modify header information - headers already sent by (output started at d:\program files\easyphp1-8\home\1.php:7) in d:\program files\easyphp1-8\home\1.php on line 17

اگه امکان داره راهنمایی کنید . مرسی

Lagon666
پنج شنبه 21 شهریور 1387, 10:06 صبح
چرا header رو بر داشتی گذاشتی پایین صفحه. بیارش بالا.

پی اچ پی Hyper Preprocessor هست. یعنی اول پردازش PHP بعد چاپ HTML.

از JavaScript هم میتونی استفاده کنی:


<script>
location.href='2.php';
</script>