I have taken over a PhP application that populates events in a MySQL database.
I have modified it so it allows events to have multiple recipients. No issues.
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.
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 <form>
tage that adddetails is hard coded into the post url as a GET paramter.
<form action="data.php?method=adddetails<?php echo isset($event)?"&id=".$event->Id:""; ?>"
class="fform" id="fmit" name="fm" method="post">
// data.php //
<?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);
?>
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 $method = $_POST["updmethod"];
my program just freezes without any error messages (I have error_reporting(E_ALL);
in my modules).
Then I tried another form to store the hidden updmethod so I could just change the method=
in
<form action="data.php?method=adddetails<?php echo isset($event)?"&id=".$event->Id:""; ?>"
class="fform" id="fm" name="fm" method="post">
to be built dynamically but am having no success there either.
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.
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.
I will not be offended if I am told my approach is all wrong, but rememeber I am working with an existing code.