dongsuyou6938 2014-03-18 00:04
浏览 25
已采纳

从Form输入Modx Revolution运行一个片段

I try to run a form in Modx Revo that the form action="" then runs a PHP snippet which inserts the input name="" into a url, that page is then parsed and inserted into the db and results are to be displayed on the same page as the form. My problem is the form is either not reading the input or the script isn't running.

My form is as follows:

<form action="[[!charAll]]" method="post">Character: <input type="text" name="char" /><br /> Realm:      <input type="text" name="realm" /><br /> <input type="submit" /></form>

My script is too long to post here but will give pieces of it for example.

The 'charAll' snippet:

$realm = $_POST["realm"];
$char = $_POST["char"];

$realm = rawurlencode($realm);
@$mstats = file_get_contents("http://us.battle.net/api/wow/character/$realm/$char?  fields=statistics,achievements", true);
$pvp = json_decode($mstats, true);

$link = mysqli_connect("127.0.0.1","dbuser","dbpw","dbname") or die("Error " . mysqli_error($link));
$link->set_charset("utf8"); 

$mname = $link->real_escape_string($pvp['name']);
$mmrealm = $link->real_escape_string($pvp['realm']);
$mclass = $pvp['class'];
$mrace = $pvp['race'];
$mgender = $pvp['gender'];  
$mlvl = $pvp['level'];
$mid = $pvp[""];

Has several more queries but for sake of space I will summarize

It then echo's (or returns) the data into a table structure that I would like to have on the same page but wouldn't mind it echo'ing on another. I know Modx Revo will be great once I get the hang of it but atm it is giving me a headache lol, any help would be greatly appreciated and I thank you in advance.

  • 写回答

1条回答 默认 最新

  • douhuai4155 2014-03-20 06:34
    关注

    The form action has to be a document, not a snippet.

    One method to do this is to use your form document, put action="[[~[[*id]]]]" on your form. Check for a posted variable, then call your charAll snippet. Then display whatever you need.

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

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料