我只是用一個簡單的動作圖像提交表單=「」去,增加了提交詳細信息到數據庫,並創建一個獨特的頁面,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);
?>
我得到了以下錯誤:'警告:在session_start()[function.session啓動]:無法發送會話緩存限制器 - 已經發出(輸出開始/首頁/里昂/的public_html/uploadimages頭。 PHP:1)在線12'和/home/lyons/public_html/uploadimages.php'警告:不能更改頭信息 - 已經(輸出發送頭開始在/home/lyons/public_html/uploadimages.php:1)在在線50'上的/home/lyons/public_html/uploadimages.php。我認爲它有什麼用$ _SESSION得到登陸用戶名和我一起做,但我可能是錯的。 –
啊,它是空格。謝謝您的幫助! –
很高興你知道了! – MrTux