Jump to content

Javascript run php function


jamiet757

Recommended Posts

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.