Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top