Frage

I would like to add unique ID at the end of my link or somewhere in the html code, that is placed in my Invoice. The link takes people to a page where they accept the terms of trade, then the email is sent as a confirmation. I can edit my invoice in Word and send it to my clients in both word docx or PDF. Is there a way of extracting from these documents a job id or their name and add it to the link they click, then forward that info with the confirmation email, so I can keep track of who accepted the terms?

Here is the code I have for an email confirmation:

<?php
session_start();
if(!isset($_SESSION))
    session_start();

if(isset($_POST['Submit']) && $_POST['termsoftrade'] == 'termsoftrade') {
    $youremail = 'email@mail.com';
    $from = 'Invoice';
    $subject = "Terms accepted";
    $message = $_POST['message']; 
    $to = $youremail;
    $headers = 'From: ' . $from . "\r\n" . 'X-Mailer: PHP/' . phpversion(); 
    $body = 'xxx has accepted the terms of trade.'; 
}

$check = $_POST['termsoftrade']; 
if ($check==false) {
    include "errormsg.php";
} else {
    include "thanks.php";
    mail($to, $subject, $body, $headers);
}
?>
War es hilfreich?

Lösung

To get the user inf from the PDF is not a simple matter. If you have control of the generation of the .pdf then this is easiest done with GET.

Create the link back to your page including the necessary data. Most PDF viewers will allow a link to be followed, but best to show the link in full so that a user can cut and paste it if needed.

link= mypage.php?uid=fsdhgfwyrt&checksum=kfgsdfgA

The uid and checksum are created by a simple algorithm:

  1. add a large number to your uid. Something with a lot of digits eg: 36183645290.
  2. take base_64 encoding of the sum and send this as uid.
  3. add 40 letters to your uid string. Take the SHA1 hash of this and base_64 encode it.
  4. send the first 8 letters as your checksum.

On receipt of the data, perform the reverse operation:

  1. base_64 decode your checksum.
  2. add your 40 letters to the uid (same ones as before!), take the SHA1 hash. If the fist 8 letters match then your uid has not been fiddled with.
  3. base_64 decode the uid
  4. subtract the original big salt number and use the uid.

You then use the uid to extract user information from your db to prepopulate the form.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top