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 script is either not reading the form input or the script isn't running at all.
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 snippet script is pretty long but I will give some of it for illustration.(table names have been changed for security.
$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[""];
$query5 = "INSERT INTO char_1 ( character_id, name, server, class, race, gender, level )
VALUES ('$mid', '$mname', '$mmrealm', '$mclass', '$mrace', '$mgender', '$mlvl')";
$result5 = $link->query($query5) or die("Error in the consult 1.." . mysqli_error($link));
$awon = $pvp['statistics']['subCategories'][9]['subCategories'][0]['statistics'][0]['quantity'];
$aplyd = $pvp['statistics']['subCategories'][9]['subCategories'][0]['statistics'][1]['quantity'];
$hpr2v2 = $pvp['statistics']['subCategories'][9]['subCategories'][0]['statistics'][24]['quantity'];
$hpr3v3 = $pvp['statistics']['subCategories'][9]['subCategories'][0]['statistics'][23]['quantity'];
$hpr5v5 = $pvp['statistics']['subCategories'][9]['subCategories'][0]['statistics'][22]['quantity'];
$rbgWon = $pvp['statistics']['subCategories'][9]['subCategories'][1]['statistics'][35]['quantity'];
$rbgPlyd = $pvp['statistics']['subCategories'][9]['subCategories'][1]['statistics'][33]['quantity'];
$hks = $pvp['totalHonorableKills'];...runs a few other queries, then echo's
the results like the following as an example...
echo " <div width='1222px' align=\'left\' valign=\'top'\ >";
echo "
<div align=\"left\" id=\"roster\" class=\"roster\">
<table class='warcraft sortable' width=\"1222px\" border=\"3\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">
<tr>
<th class='sorttable_nosort'><width=\"50\" align=\"center\"><strong>Race/Class</strong></th>
<th class='sorttable'><width=\"200\" align=\"center\"><strong>Name</strong></th>
<th width=\"30\" align=\"center\"><strong>Lvl</strong></th>
<th class='sorttable_nosort'><width=\"100\" align=\"center\"><strong>XPRank</strong></th>
<th width=\"60\" align=\"center\" ><strong>PVPAP</strong></th>
<th width=\"60\" align=\"center\" ><strong>ARAP</strong></th>
<th width=\"60\" align=\"center\" ><strong>RBGAP</strong></th>
<th width=\"60\" align=\"center\" ><strong>ARPLD</strong></th>
<th width=\"60\" align=\"center\"><strong>ARWON</strong></th>
<th width=\"60\" align=\"center\"><strong>HPR2v2</strong></th>
<th width=\"60\" align=\"center\"><strong>HPR3v3</strong></th>
<th width=\"60\" align=\"center\"><strong>HPR5v5</strong></th>
<th width=\"60\" align=\"center\"><strong>RBGPLD</strong></th>
<th width=\"60\" align=\"center\"><strong>RBGWON</strong></th>
<th width=\"60\" align=\"center\"><strong>PvpXP</strong></th>
<th width=\"60\" align=\"center\"><strong>HKs</strong></th>
</tr>
"; an array result then...
echo "
<tr>
<td align=\"center\"><strong><img style=\"padding-left: 3px;\" src=\"img/race/$mrace-$mgender.gif\"></img><img style=\"padding-left: 3px;\" src=\"img/class/$mclassid.gif\"></img></strong></td>
<td class='class_$mclassid' width=\"200\" align=\"left\"><strong>$mname</strong></td>
<td class='class_$mclassid' width=\"30\" align=\"center\"><strong>$mlevel</strong></td>
<td class='class_$mclassid' width=\"100\" align=\"center\"><strong>$rank</strong></td>
<td class='class_$mclassid' width=\"60\" align=\"center\" ><strong>$pvpp</strong></td>
<td class='class_$mclassid' width=\"60\" align=\"center\" ><strong>$arp</strong></td>
<td class='class_$mclassid' width=\"60\" align=\"center\" ><strong>$rbgp</strong></td>
<td class='class_$mclassid' width=\"60\" align=\"center\"><strong>$aplyd</strong></td>
<td class='class_$mclassid' width=\"60\" align=\"center\"><strong>$awon</strong></td>
<td class='class_$mclassid' width=\"60\" align=\"center\"><strong>$hpr2v2</strong></td>
<td class='class_$mclassid' width=\"60\" align=\"center\"><strong>$hpr3v3</strong></td>
<td class='class_$mclassid' width=\"60\" align=\"center\"><strong>$hpr5v5</strong></td>
<td class='class_$mclassid' width=\"60\" align=\"center\"><strong>$rbgPlyd</strong></td>
<td class='class_$mclassid' width=\"60\" align=\"center\"><strong>$rbgWon</strong></td>
<td class='class_$mclassid' width=\"60\" align=\"center\"><strong>$pvpXP</strong></td>
<td class='class_$mclassid' width=\"60\" align=\"center\"><strong>$hks</strong></td>
</tr>
";
}
echo " ";
The script runs fine outside of Modx so I know the script is working and so is the form, I just can't seem to get it to work in Modx.
I know Modx Revo will be great once I get the hang of it but atm it is giving me a headache lol, I am very new to web dev and even newer to Modx, any help would be greatly appreciated and I thank you in advance.