Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems with PhP Yes/No and Switch/Case routine
    text
    copied!<p>I have taken over a PhP application that populates events in a MySQL database.</p> <p>I have modified it so it allows events to have multiple recipients. No issues.</p> <p>My issue is that when a multi user event is clicked on to update or more importantly to delete I ask using a Javascript function 'Apply to all users on this event?'. Question works fine. I appreciate PhP is server side and JS runs on the client side. </p> <p>So what I tried is a hidden field in my edit form which defaults to 'adddetails' and if they press yes to the multi user question populate it with addmultidetails (which I verified by making a text field temporarily). You can see from the original <code>&lt;form&gt;</code> tage that adddetails is hard coded into the post url as a GET paramter.</p> <pre><code>&lt;form action="data.php?method=adddetails&lt;?php echo isset($event)?"&amp;id=".$event-&gt;Id:""; ?&gt;" class="fform" id="fmit" name="fm" method="post"&gt; </code></pre> <p>// data.php //</p> <pre><code>&lt;?php session_start(); function add($st, $et, $sub, $ade){ return $ret; } function addDetailed($st, $et, $sub, $ade, $dscr, $loc, $color, $tz){ return $ret; } function listByRange($sd, $ed){ return $ret; } function list($day, $type){ } function update($id, $st, $et){ return $ret; } function updateDetailed($id, $st, $et, $sub, $ade, $dscr, $loc, $color, $tz){ return $ret; } function updateMultiDetailed($id, $st, $et, $sub, $ade, $dscr, $loc, $color, $tz){ return $ret; } function remove($id){ return $ret; } $method = $_GET["method"]; switch ($method) { case "add": break; case "list": break; case "update": break; case "remove": break; case "adddetails": break; case "addmultidetails": break; } echo json_encode($ret); ?&gt; </code></pre> <p>All the post data as originally posted is correct, however if I try to access the hidden field, updmethod, and changed the data.php to have <code>$method = $_POST["updmethod"];</code> my program just freezes without any error messages (I have <code>error_reporting(E_ALL);</code> in my modules).</p> <p>Then I tried another form to store the hidden updmethod so I could just change the <code>method=</code> in </p> <pre><code>&lt;form action="data.php?method=adddetails&lt;?php echo isset($event)?"&amp;id=".$event-&gt;Id:""; ?&gt;" class="fform" id="fm" name="fm" method="post"&gt; </code></pre> <p>to be built dynamically but am having no success there either.</p> <p>I would appreciate any help with this. I am not being lazy. I have spent 2 days working on a problem I thought I could resolve quickly and have read 'tutorials' on Server side/Client side relationship. Tried to understand Ajax etc but no matter what I seem to achieve I then encounter another wall.</p> <p>I know my problem all stems from the Php/Javascript realtionship and trying to get the response from the Javascript function to my Php....but I am stumped.</p> <p>I will not be offended if I am told my approach is all wrong, but rememeber I am working with an existing code.</p>
 

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