duanbinren8906 2014-04-09 16:57
浏览 58
已采纳

如何让用户编辑PHP文件?

Okay These types of questions are normally very broad, however I will try my best to explain exactly what I want to try and achieve.

What I want is to allow users to enter some information (This will be an IP Address) using a HTML input form, and then once they click submit the data they entered would be added to the PHP code where they can then see the results. Here's the PHP code (Only a snippet of some of the code.)

$SERVER_IP="//IP OF USER INPUT WOULD GO HERE"; 

I understand that this could possibly be more of a task than simply just adding a HTML input form a few lines of code, if this is the case, could you please point me to where I can get information on how to do these sort of things?

Thanks you.

  • 写回答

2条回答 默认 最新

  • dongya6395 2014-04-09 17:02
    关注

    If it doesn't need to be permanent, use a form, then access the variable by $_GET['var'] or $_POST['var']. You can even save it to the user's $_SESSION. If it needs to be permanent, use a database..don't have a user edit your PHP

    You can also use something like jQuery to append data to a div container, example:

    HTML:

    <input id="input_form_id" type="text"/>
    <button id="add_ip">Add</button>
    <div id="ip_addresses"></div>
    

    Jquery:

    $("#add_ip").click(function() {
        var ip = $("#input_form_id").val();
        $("#ip_addresses").append(ip + "<br/>");
    });
    

    Jsfiddle: http://jsfiddle.net/hvBwK/

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

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度