0

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);
}
?>
Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Radi
  • 83
  • 3
  • 13
  • Add `$subject = "Your subject";` near the top after `$fromsubject = 'Request from form';`. Give that a try and let me know how it works out for you. – Funk Forty Niner Jun 22 '13 at 21:44
  • ^^ Partial answer to your question. – Funk Forty Niner Jun 22 '13 at 21:57
  • That worked! Thanks Fred! But that's only a small thing, I am waiting for someone who can help me with the big one..Thanks anyway!;) – Radi Jun 22 '13 at 21:58
  • You're welcome. Would've been better if I could've been more help. – Funk Forty Niner Jun 22 '13 at 21:59
  • Actually, maybe you can.. another small thing, the email I am getting has a From field like this "User G150962", how can I change that? – Radi Jun 22 '13 at 22:02
  • Which variable are you using for it, is it in your code above? – Funk Forty Niner Jun 22 '13 at 22:04
  • Thats not from the code, it looks like its from the hosting company, the email I am getting starts from this number like this g150962@myhostingcomany.com. Lets continue the discussion in the standard post, they want me to avoid extended discussion in comments. – Radi Jun 22 '13 at 22:06
  • Assuming the `email ID FROM` is called `$from_email` (in your form), you could use something like this `$headers = 'From: '.$from_email."\r\n". 'Reply-To: '.$from_email."\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $body, $headers);` – Funk Forty Niner Jun 22 '13 at 22:11
  • I don't have $from_email in my form nowhere, also where that code goes? Thanks – Radi Jun 22 '13 at 22:19
  • Then try this: Put this `$headers = 'From: '.$your_email."\r\n". 'Reply-To: '.$your_email."\r\n" . 'X-Mailer: PHP/' . phpversion();` **below** `$to = $youremail;` **then replace** `mail($to, $subject, $body);` **with** `mail($to, $subject, $body, $headers);` – Funk Forty Niner Jun 22 '13 at 22:25
  • Another hit! Thanks it's working perfect! – Radi Jun 22 '13 at 22:38

1 Answers1

0

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.

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Robert Seddon-Smith
  • 987
  • 1
  • 9
  • 13
  • Hi Robert, thanks for your answer, but Im not a PHP developer and don't really know what to do with this. Is there some kind of code that can do this somewhere on the internet? How can I look for it? What key words should I use? Thanks again! – Radi Jun 22 '13 at 22:24
  • @Radi I found the following link on **SO**, which may be of help: http://stackoverflow.com/questions/6999889/how-to-extract-text-from-the-pdf-document – Funk Forty Niner Jun 22 '13 at 22:42
  • It looks ok, although it gives text file output from what I see... so it would be only a part of the job done. I need to extract invoice number or name from my PDF and include that in the email we were working on a while ago. Or any other way I can be notified that my client accepted the terms of trade. So far they can accept, but it is not related with the invoice given. – Radi Jun 22 '13 at 23:05