douzhao7445 2013-08-20 13:57
浏览 22
已采纳

如果仅来自特定页面,则允许访问页面

My case:

  1. articlesubmitted.php - read the last article information from a specific username from the database.
  2. addarticle.php - add article to database.

I want to do articlesubmitted.php accept visits ONLY from addarticle.php and if is possible to be readed just 1 time by the user which he submitted the article.

I found something with REQUEST_URI but can't make to work.

How can I do that? it is possible to made from .htaccess?

  • 写回答

3条回答 默认 最新

  • dongzhong8691 2013-08-20 14:05
    关注

    Try using the following example with your present code:

    HTML LINK (link_for_get_access.php)

    <a href="get_access.php">GO HERE</a>
    

    get_access.php

    <?php
    
    if (strstr($_SERVER['HTTP_REFERER'],"example.com/link_for_get_access.php"))
    
    {
    
    echo "<h1>You have access.</h1>";
    
    }
    else
    {
    
    echo "<h1>Sorry, you don't have access.</h1>";
    
    }
    
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?