PHP to send email with buttons that prompts answer from recipient and send back value to actual database

I would like to ask, how can i make the email i sent out to consist of two buttons which is accept or reject that when the recipient click on reject/accept, the value actually sends back to the database.

Does anyone have idea on this method ?


$subject1="E-Calibration Registration Form Approval Notice for HOD";
            $message1="Dear HOD, you currently have a pending E-Calibration Registration Form waiting for approval.";
            //starting outlook        

            if (!defined("olMailItem")) {define("olMailItem",0);}
            $outlook_Obj1 = new COM("outlook.application") or die("Unable to start Outlook");
            //just to check you are connected.        
            echo "<center>Loaded MS Outlook, version {$outlook_Obj1->Version}\n</center>";
            $oMsg1 = $outlook_Obj1->CreateItem(olMailItem);        
            echo "</br><center>Email has been sent succesfully</center>";

This is my php code for my email

1 answer

  • answered 2021-04-08 03:28 Beaton Nyamapanda

    So this functionality should start in the email you are sending. The email template or code should first of all be HTML to be able to accommodate the buttons. So the email mode should be HTML. These buttons can be linked to a form or direct links which denote Accept or Reject actions.

    These can be the PHP file which then sends that information to the database.

    <input type="submit" name="accept" value="Accept">
    <input type="submit" name="accept" value="Reject">

    Then in your PHP code, you can have your normal code to read these values and store them in the database.

    if ($_SERVER["REQUEST_METHOD"] == "POST") {
          // collect value of input field
         $data = $_REQUEST['accept'];
         // store in DB