Closed. This question needs details or clarity。它当前不接受答案。
                        
                    
                
            
        
            
        
                
                    
                
            
                
                    想改善这个问题吗?添加详细信息并通过editing this post阐明问题。
                
                    6年前关闭。
            
        

    

我们刚刚在Intranet上实现了一个表格,该表格允许IT中的任何人(接近100人)使用特定的Twitter帐户向我们的用户发送推文。有没有一种方法可以存储在服务器上或在特定时间加载页面的其他地方,或者更好的是,谁可以填写并提交表单?

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


编辑:重新审视这一点,我试图实现的目标是在包含用户名的表单中获取一个隐藏变量(在IIS中禁用了匿名功能),回首这句话的措辞很糟糕,因为我不知道自己在做什么。

最佳答案

如果要获取用户的IP地址,则只需使用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;
}


然后,只需将其作为隐藏变量发送,并将其存储在某个地方,例如mysqli数据库或包含推文的文件即可。

10-02 01:23
查看更多