我有一个通常的形式将值发送到 php 文件。
<form action=\"/admin/save\" method=\"post\" ENCTYPE=\"multipart/form-data\">
<div class=\"element\">
<label for=\"name\">Page ID <span class=\"red\">(required)</span></label>
<input id=\"id\" name=\"id\" value=".$edit['id']." class=\"text\" />
</div>
<div class=\"element\">
<label for=\"name\">Page title <span class=\"red\">(required)</span></label>
<input id=\"title\" name=\"title\" value=".$edit['title']." class=\"text\" />
</div>
<div class=\"element\">
<label for=\"category\">Category <span class=\"red\">(required)</span></label>
<input id=\"category\" name=\"category\" value=".$edit['category']." class=\"text\" />
</div>
<div class=\"element\">
<label for=\"attach\">Attachments</label>
<input type=\"file\" id=\"img\" name=\"img\" />
</div>
<div class=\"element\">
<label for=\"short-content\">Short content <span class=\"red\">(required)</span></label>
<textarea name=\"short_content\" id=\"short_content\" class=\"textarea\" rows=\"10\">".$edit['short_content']."</textarea>
</div>
<div class=\"element\">
<label for=\"content\">Long content <span class=\"red\">(required)</span></label>
<textarea name=\"long_content\" id=\"long_content\" class=\"textarea\" rows=\"10\">".$edit['content']."</textarea>
</div>
<div class=\"element\">
<label for=\"date\">Date <span class=\"red\">(required)</span></label>
<input id=\"date\" name=\"date\" class=\"text\" value=".$edit['date']." />
</div>
<div class=\"element\">
<label for=\"language\">Language <span class=\"red\">(required)</span></label>
<input id=\"language\" name=\"language\" value=".$edit['lang']." class=\"text\" />
</div>
<div class=\"entry\">
<button type=\"submit\" id=\"button-save\" class=\"add button-save\">Save page</button>
</div>
</form>
发送至..
<?php include('/views/admin/header.php'); ?>
<div class="wrap">
<div id="header">
<div id="top">
<div class="left">
<p>Welcome, <strong><?php echo $_SESSION['user'];?></strong> [ <a href="/admin/logout">logout</a> ]</p>
</div>
<div class="right">
<div class="align-right">
<p>Avetisyan | Admin Panel</p>
</div>
</div>
</div>
<div id="nav">
<?php include '/views/admin/upper-menu.php'; ?>
</div>
</div>
<div id="content">
<div id="sidebar">
<div class="box">
<div class="h_title">› Pages</div>
<?php include '/views/admin/left-menu.php'; ?>
</div>
</div>
<div id="main">
<div class="full_w">
<?php
$id = $_POST['id'];
$category = $_POST['category'];
$title = $_POST['title'];
$short_content = $_POST['short_content'];
$long_content = $_POST['long_content'];
$date = $_POST['date'];
$lang = $_POST['language'];
if(empty($id)){
echo "<h3 style=\"color:red;\">Please fill ID</h3>";
}
if(empty($category)){
echo "<h3 style=\"color:red;\">Please fill Category</h3>";
}
if(empty($title)){
echo "<h3 style=\"color:red;\">Please fill Title</h3>";
}
if(empty($date)){
echo "<h3 style=\"color:red;\">Please fill Date</h3>";
}
if(empty($lang)){
echo "<h3 style=\"color:red;\">Please fill Lang</h3>";
}
if(isset($_FILES['img']['name'])){
$extension = end(explode(".",$_FILES['img']['name']));
//echo "file format: ".$extension."<br>";
$name = $_FILES['img']['name'];
$size = $_FILES['img']['size'];
if(file_exists("views/admin/uploads/".$name)){
echo $_FILES['img']['name']." exists";
}
if($extension != "jpg" && $extension != "png" && $extension != "gif"){
echo "File with format: ".$extension." is not aviable to upload";
}
if($size > 1000000) {
echo $size." is greater than 1 mb !";
}
else {
move_uploaded_file($_FILES['img']['tmp_name'],"views/admin/uploads/".$name);
}
}
?>
</div>
<div class="clear"></div>
</div>
<div id="footer">
<div class="left">
<p><a href="http://webex.am">Webex Technologies LLC</a> | Admin Panel: <a href="/">Avetisyan</a></p>
</div>
<div class="right">
</div>
</div>
</div>
<?php include('/views/admin/footer.php');?>
在第二个文件中,我想做一个链接,所以如果用户写错了,他点击那个链接,回到编辑页面(编辑页面链接看起来像这样 - /admin/edit?id=5&lang=arm)。我如何通过 post 方法而不是通过输入发送 $_SERVER['request_uri'] ,我不想有另一个输入。或者你可以在这里给我任何解决方案吗?