【发布时间】:2014-05-10 10:26:00
【问题描述】:
谁能告诉我为什么我的标头重定向不起作用?
这是我的代码:
<?php
include('includes/connect.php');
include('includes/link.php');
include('includes/time_stamp.php');
session_start();
$id = $_SESSION["id"];
$username = $_SESSION["username"];
$path = "uploads/";
$valid_formats = array("jpg", "png", "gif", "bmp", "jpeg");
$name = $_FILES['photoimg']['name'];
$size = $_FILES['photoimg']['size'];
list($txt, $ext) = explode(".", $name);
$actual_image_name = time().substr(str_replace(" ", "_", $txt), 5).".".$ext;
$tmp = $_FILES['photoimg']['tmp_name'];
move_uploaded_file($tmp, $path.$actual_image_name);
$time=time();
$ip=$_SERVER['REMOTE_ADDR'];
mysql_query("INSERT INTO `messages` (message, id_fk, ip,created) VALUES ('$actual_image_name', '$id', '$ip','$time')");
header("Location: index.php");
?>
谢谢
【问题讨论】:
-
您的脚本是否正确插入数据库?
-
是的,数据库插入出现了。
-
那么当你执行这个脚本时你在屏幕上看到了什么?
-
首先将
mysql_query包装在一个条件中,甚至在重定向之前检查它是否执行或因异常而死。 -
页面只是空白。
标签: php html mysql redirect url-redirection