Note that there are some explanatory texts on larger screens.

plurals
  1. POIntegrating legacy Ajax script in CakePHP
    primarykey
    data
    text
    <p>I have a legacy script that I would like to integrate in a cakephp app. The script makes use of $_POST and such and since I'm quite a noob I would need some help for the integration.</p> <p>Here is how the script looks like:</p> <p>THE JAVASCRIPT:</p> <ul> <li>prototype.js</li> <li>builder.js (these two are from the prototype fw)</li> <li><strong>lib.js (makes a ajax requests to remote.php)</strong></li> </ul> <p>THE PHP</p> <ul> <li><p><strong>remote.php (contains FastJSON class and $_POST vars)</strong></p> <pre><code>if ($_POST['cmd'] == 'SAVETEAM' &amp;&amp; $_POST['info']) { $INFO = json_decode(str_replace('\"', '"', $_POST['info'])); $nr = 1; $SORT = array($INFO-&gt;GK, $INFO-&gt;DEF, $INFO-&gt;MID, $INFO-&gt;FOR, $INFO-&gt;RZ); foreach ($SORT as $STD) foreach ($STD as $v) mysql_query("UPDATE players_teams SET fieldposition = ".$nr++." WHERE player_id = {$v-&gt;player_id} AND team_id = {$v-&gt;team_id}") or die(mysql_error()); // CAPTAION mysql_query("UPDATE `teams` SET captain = '{$_POST['captain']}' WHERE `user_id` = {$_POST['userid']}") or die(mysql_error()); </code></pre> <p>}</p></li> <li><p>transfers.php (containts the form that uses the javascript and link to the JS)</p></li> </ul> <p>I have really no idea how to structure the files and calls in cakephp. Currently I have "Undefined index: cmd [APP/vendors/remote.php, line 230]" errors since I use $_POST['cmd'] (I placed remote.php in Vendors and included it, the JS was just included old fashion way, as a link and appears in the source code). How can I make this work? I'm sorry but I'm not familiar with AJAX and Cake... If you want a full look at the code, here it is: <a href="http://octavian.be/thecode.zip" rel="nofollow noreferrer">http://octavian.be/thecode.zip</a></p> <p>Thank you for reading and helping me out.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload