douhui9380 2013-06-17 07:55
浏览 25
已采纳

通过邮寄发送$ _SERVER ['request_uri']

i got a usual form sending values to php file.

<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>

Sends to..

<?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">&#8250; 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');?>

In second file, i want to do an link back, so if user wrote something wrong, he click on that link, go back to edit page (edit page link look like this - /admin/edit?id=5&lang=arm). How i can send $_SERVER['request_uri'] via post method but not via inputs, i dont want to have there another input with it.. Or can u give me any solution here?

  • 写回答

2条回答 默认 最新

  • doupapin172773 2013-06-17 07:59
    关注

    Use $_SERVER['HTTP_REFERER'] in the file you process the submission.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)