Link to home
Start Free TrialLog in
Avatar of sharepoint2015
sharepoint2015

asked on

PHP parsing email address

Hi Experts,

I've a HTML email which I email out to people to click on the link.

How do I embed the person's email into the link in the HTML email when clicked to parse into the PHP form?

eg: If the person who opens the email, his email is john@doe.com, when he opens this email and click on the link to go to the webpage, his email will be automatically populated on the webpage textfield saying "john@doe.com"

this is the code

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta id="viewport" name="viewport">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
       <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Pre qualification email</title>
        <link rel="stylesheet" href="http://www.personalclaimline.com/css/main.css">
        <link href="http://fonts.googleapis.com/css?family=PT+Sans:400,700,400italic,700italic" rel="stylesheet" type="text/css">
         <!--[if lte IE 9]>
          <script type="text/javascript" src="http://www.personalclaimline.com/js/html5shiv.js"></script>
        <![endif]-->

     
</head>
    <body background="http://www.personalclaimline.com/img/form-background.jpg">
    
    <div class="jquery-script-ads" align="center"> </div>
      <main>
    
   
      
      
      
        <h1>Urgent: Pre qualification email</h1>
   
   
	  
          <p>Mr. Mrs_________<br>
            Claim no: Euroclaim SG/023</p>
          <p>In the world of corporate  litigation, information is power. Please click &ldquo;yes&rdquo; or &ldquo;no&rdquo; on your personal self  assessment form below to assist us to maximise your claim.<br>
            You may qualify for up to  four times your loss in compensation on top of your refund. <br><br>
            Under: <u>Section 340, Chapter 20 of the Companies Act</u><br>
            Your company may have  committed the following breaches of law: </p>
          <p align="center"><em>Criminal Breach of Trust, Material  Harm, Defraudulent Trading.</em></p>
<p class="form-help-text">&nbsp;</p>
<form>
        <fieldset data-role="controlgroup" data-type="horizontal" data-mini="true">
          <legend>Qualify for refund:</legend>
          If you can't see the rest of the form please <a href="http://www.personalclaimline.com/email.php?to=feedback@personalclaimline.com">click here</a> to qualify for your refund + 400% compensation.
</fieldset>
      </form>   
      </main>
      
    
    </body>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Insoftservice inso
Insoftservice inso
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Have a look at this article.  The web server that contains the "handshake" script can prepopulate any field in the HTML form as it generates the page (any field except FILE, but that's not in play here).
https://www.experts-exchange.com/Programming/Languages/Scripting/PHP/A_3939-Registration-and-Email-Confirmation-in-PHP.html

If you follow this design, the server has control over the data that goes into the form, and there is less risk of tampering with the email message.
Avatar of sharepoint2015
sharepoint2015

ASKER

let me try it.
Hello sharepoint2015,
So the PHP that creates the email HTML needs to add the email address into the link before it sends the email. It needs to be added during the email construction. This way, when the link is clicked you are passing the email address as a parameter to the websites form page (which will pop-up in a new browser window). When the person clicks the link it already should have the email address included as a parameter. The page with your form then retrieves the parameter and uses it to populate the appropriate HTML label, input box, or variable.

<a href="http://www.personalclaimline.com/email.php?to=feedback@personalclaimline.com">click here</a>

In the code above that you have included it looks like you have already done this. Perhaps you did this manually as an example. Inserting the address into the link during email construction is simple string building. You may already know how to do this. Just in case, I will explain...

<?php
$theemailaddress="feedback@personalclaimline.com";
echo "<a href=\"http://www.personalclaimline.com/email.php?to=".$theemailaddress."\">click here</a>";
?>

Notice where " is echoed we use the \ escape character. This tells the echo to include the " in the string so that the string does not end. Using the . to concatenate variables to a string makes the variable stand out so that it is easier to read.

Hope this helps. Worth a try.
Avatar of p_nuts
let's keep it simple..

you've got an email with a link http://www.personalclaimline.com/email.php?to=feedback@personalclaimline.com

on the page email.php the "to" variable is avialable through $_GET['to']

so if you want to use that furtheron or want to display it just use that.

if you want to change the to variable to an ID stored in the DB that's pretty easy too but you are probably better off using ray's registration article and make it a full blown registration.

P_nuts