douduandiao1368 2012-07-19 00:07
浏览 54

http.responseText返回名为的PHP函数的名称

I am using AJAX to call a function within PHP. It returns my data fine but, it keeps putting the function name at the beginning of the returnText.

My Javascript/ajax

function getfirst() {
    var myphp=document.getElementById('myphp').value ;
    http=createRequestObject();
    url= tablename + '.php?filename=' + tablename;
    url= url + '&function=movefirst';
    url= url + '&seekindex=CustomerKey';
    url= url + '&maxdata=' + maxdata;
    http.open('GET',url,false);
    http.send(null);
    document.getElementById('myreturn').value;
}

MY PHP

<?php include '../../tophat.php';

$_REQUEST['function']();

function movefirst(){
    $filename=$_REQUEST['filename'];
    $seekindex=$_REQUEST['seekindex'];
    $maxdata=$_REQUEST['maxdata'];
    opendbdata();
    $query="SELECT * FROM ". $filename . " ORDER BY " . $seekindex; 
    $result=mysql_query($query);
    $returnkey='';
    for ($i=0; $i<=$maxdata-1; $i++)  {
         $returnkey = $returnkey . mysql_result($result,0,$i) . "~";
    }
    echo $returnkey;
}

I'm looking up the first customer in my customer database it returns the record but at the beginning of the returnText is the name of the function. Here is the beginning of the .returnText: "movefirst4SEASONS1~4 Seasons Pottery~336 Hammond Dr NE~"

I have never had this problem before. Thanks in advance for your help.

  • 写回答

2条回答 默认 最新

  • dtq7387 2012-08-22 15:19
    关注

    Note that you

    • allow users to execute any functions that are available in this scope (something like dropDatabase() or rebootServer()) since you're invoking $_REQUEST['function']
    • allow users to make any changes in your database or read secret information by taking advantage of SQL Injection!
    评论

报告相同问题?

悬赏问题

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