jamiet757 Posted February 9, 2010 Share Posted February 9, 2010 I am trying to get my site script to send an email to a user when I click on an Approve or Declined link, here is the javascript that handles the clicking: function fstatus(fid,fdo,ftable) { var req = new JsHttpRequest(); // Code automatically called on load finishing. req.onreadystatechange = function() { if (req.readyState == 4) { document.getElementById('status'+fid).innerHTML =req.responseText; } } req.open(null, 'status.php', true); req.send( {'fid':fid,'fdo':fdo,'ftable':ftable} ); } Here is the status.php file: <?php include("../function/db.php"); if($_SESSION['entry_admin']!=1){redirect("../auth/");} include("../../members/JsHttpRequest.php"); $JsHttpRequest =& new JsHttpRequest("iso-8859-1"); $id=(int)@$_REQUEST['fid']; $doc=@$_REQUEST['ftable']; $fdo=(int)@$_REQUEST['fdo']; $sql="select id_parent,published from ".$doc." where id_parent=".$id; $rs->open($sql); if(!$rs->eof) { $sql="update ".result($doc)." set published=".$fdo." where id_parent=".$id; $db->execute($sql); ?> <a href="javascript:fstatus(<?=$rs->row["id_parent"]?>,1,'<?=$doc?>');" <?if($fdo!=1){?>class="gray"<?}?>>Approved</a><br> <a href="javascript:fstatus(<?=$rs->row["id_parent"]?>,0,'<?=$doc?>');" <?if($fdo!=0){?>class="gray"<?}?>>Pending</a><br> <a href="javascript:fstatus(<?=$rs->row["id_parent"]?>,2,'<?=$doc?>');" <?if($fdo!=2){?>class="gray"<?}?>>Declined</a> <?php } ?> I want to run a php function that will send an email whenever I click one of the links, and I need a way to select which email to send. I can figure out how to get it to send the email, I just can't figure out how to make it happen when I click one of the links. I am not familiar with javascript at all. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.