我有一个图像提交表单,它只使用一个简单的action =“”来访问一个PHP页面,该页面将提交详细信息添加到数据库并为提交创建一个唯一的页面。这很好。但是,我希望它重定向到他们的提交页面(用fwrite()创建)我该怎么做?代码如下。
<?php
// For use in creating individual page
$tpl_file = "submission.php";
$tpl_path = "templates/";
$submissions_path = "submissions/";
// For use in querying submitter name
$username = $_GET['username'];
session_start();
$_SESSION['username'] = $username;
//Database Information
$dbhost = "";
$dbname = "";
$dbuser = "";
$dbpass = "";
//Connect to database
mysql_connect ($dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$name = $_GET['right_form_title'];
$filename = $_GET['right_form_url'];
$submitter = $username;
$type = exif_imagetype($_GET['right_form_url']);
list($width, $height) = getimagesize($filename);
$query = "INSERT INTO images (name, filename, submitter, width, height, type)
VALUES('$name', '$filename', '$submitter', '$width', '$height', $type)";
mysql_query($query) or die(mysql_error());
mysql_close();
$php_file_name = $name.".php";
$path_for_link = $submissions_path.$php_file_name;
$tpl = file_get_contents($tpl_path.$tpl_file);
$tpl_and_values = preg_replace("(%([a-z_][a-z0-9_]*)%)ie",'$$1',$tpl);
$fh = fopen($submissions_path.$php_file_name, "w");
fwrite($fh, $tpl_and_values);
fclose($fh);
?>
答案 0 :(得分:2)
关闭文件后添加此文件就可以了。
header('location: '.$submissions_path.$php_file_name);
答案 1 :(得分:1)
我相信您需要做的就是在该文件的底部粘贴一个标题,该标题将重定向到新创建的文件。尝试在文件底部添加此内容。
header('Location: '.$submissions_path.$php_file_name);