dou8mwz5079 2014-01-21 12:51
浏览 18
已采纳

提交表格的商店? [关闭]

we have just implemented an form on our intranet that allows anyone in IT (close to 100 people) the ability to tweet out to our users using a particular twitter account. Is there a way to store on the server or elsewhere who loaded the page at a particular time, or, even better, who filled in and submitted the form?

<div style="float: right; width: 450px; padding:20px;">
Use the box below to send out a tweet unrelated to the system status updates further down.<br />
<form name="MaffTwitterText" target="invisibleForm2" id="MaffTwitterText" action="./TweetText.php" method="post">
<textarea name="tweetMafftext" id="textarea" style="width:100%; height: 80px;" maxlength="140" placeholder="Enter your tweet here"></textarea>
<button type="submit" >
Click once only to send tweet
</button><br><iframe name="invisibleForm2" id="invisibleForm2" width="100px" height="25px" frameborder="0" scrolling="no"></iframe>
</form>
</div>

EDIT: revisiting this, What I was trying to achieve was to get a hidden variable within the form that contained the user's name (anonymous is disabled in IIS), looking back this was very badly worded as I didn't know what I was doing.

  • 写回答

1条回答 默认 最新

  • duanraotun1674 2014-01-21 12:57
    关注

    If you are referring to getting the IP address of the user, just use the function from https://stackoverflow.com/questions/1437771/how-can-i-get-the-clients-ip-address-in-a-php-webservice:

    public static function get_remote_ip() {
        if(isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR'])) {
            return $_SERVER['REMOTE_ADDR'];
        } 
    
        if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
            return $_SERVER['HTTP_X_FORWARDED_FOR'];
        }
    
        return null;
    }
    

    Then just send that as a hidden variable and store it somewhere such as a mysqli database or a file including the tweet with it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 如何将下列的“无限压缩存储器”设计出来
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口