Jump to content

Recommended Posts

Hello, I know how to send something to an email. How can I add a link to the email so that if someone clicks on the link some php will execute?

 

What php I want to execute is that when they click on the link the letter "v" is sent to a database. I know how to send something to a database, I just don't know how to tie all this together with the an address link in their email.

 

All I'm trying to do is send something to someones email and when they click on the link it will prove there email is real and not a bogus email address. I'm just missing this one piece on    -----how to make the web site address link in their email activate some php.

 

Please let me know, thanks a lot.

Link to comment
https://forums.phpfreaks.com/topic/64477-adding-php-to-the-message-of-an-email/
Share on other sites

the link you send in an email should contain http://example.com?letter=v

 

then when the person clicks the link and taken to http://example.com?letter=v you will want to set up your code on page http://example.com to accept the value of letter, which in this case would be v. The way to do that is to use $_GET['letter'] and then setup your datbase query to something like "INSERT INTO tablename (letter) VALUES '$_GET['letter']'";

Thank you, I appreciate that very much. The emails aren't accepting regular html.

It doesn't let me put a closing tag on the A link in this forum but my following A link is correct.

 

$messageproper = "<a href='validationpage.php'>why arent emails accepting this html?<closingslash a>"

 

Please let me know, thanks.

Heres the link I'm using for html in emails. http://www.w3schools.com/php/func_mail_mail.asp

 

Here's what I'm using in the php and the email is sending, but it shows this just as is in the email. Its not reading any of this as html. Anyone see whats wrong with my html email code? Thanks.

 

$validateemail = 'anemail@address.com ;
$from = 'noreplysupportaddress';
$subject = "Email validation" ; 
$messageproper = "<html>
<head>
<title>HTML email</title>
</head>
<body>
<div><span style='font-family:arial,sans-serif;font-size:14px'>Testing text and html in an email.<a href='http:www.example.com/validate.php?username=$username
' target='blank'>Validate Your Email</a></span></div>
</body>
</html>";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers = "From: <$from>\r\n";
$headers .= "Reply-To: ".preg_replace('/[\r\n]+/', ' ', $from)."\r\n";
mail($validateemail, $subject, $messageproper, $headers);

<span style='font-family:arial,sans-serif;font-size:14px'>Testing text and html in an email.<a href='http:www.example.com/validate.php?username=$username

' target='blank'>

 

try

<span style=\"font-family:arial,sans-serif;font-size:14px\">Testing text and html in an email.<a href=\"http:www.example.com/validate.php?username=$username
\" target=\"blank\">

Strange, didn't help, I also sent it to two other emails, aol and a no name brand. Same thing, doesn't read the html. or the A link even all by itself with the escape slashes. I've been reading all over google, its working for everyone else, why not for me?

heres the code I use and it works evertime.

 

$headers = 'From: me@mydomain.com' . "\r\n" .
    	'Reply-To: me@mydomain.com'  . "\r\n" .
    	'X-Mailer: PHP/' . phpversion();
	$subject = "Subject Line";
	$message = "Dear SonSo, this is your activation link to join our website. In order to confirm your membership please click on the following link: http://www.xxxx.com/xxxx/confirm.php?ID=1 Thank you for joining";
	mail(theiremail@theirdomain.com, $subject, $message, $headers)

 

Sometimes I add a a random key to the link so that it is a more secure confirmation.

Thanks, how are they able to click on your link, I don't see a link. I need to know how to do html in an email for other reasons as well. So I can format some emails I send. Here's all of it. Its only reading html like this <span> etc. How to get an email to read html? Thanks very much.

 

<?php 
?> 
<form action="<?php $_SERVER['PHP_SELF'] ;?>" method='post'> 
<input type='text' name='username' size=15> <span>User name</span><br /> 
<input name='email' size=15> <span>Email</span><br /> 
<input type='submit' name="submit" value='Submit'><br /><br /> </form> 
<?php 
if (isset($_POST['submit'])) { 
$username = $_POST['username'] ; 
$pemail = $_POST['email'] ; 
$from = 'noreplysupport@somesite.com'; 
$subject = "Validation Email" ; 
$messageproper = "<span style=\"font-family:arial,sans-serif;font-size:14px\">Just click on the following link to validate your email.</span> <a href=\"http://www.example.com/validate.php?username=$username\" target=\"blank\">Validate</a>"; 
$headers = "MIME-Version: 1.0" . "\r\n"; 
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; 
$headers = "From: <$from>\r\n"; $headers .= "Reply-To: ".preg_replace('/[\r\n]+/', ' ', $from)."\r\n"; 
mail($pemail, $subject, $messageproper, $headers); } ?>  

This doesn't work either: $messageproper = "<html><body><div><span style='font-family:arial,sans-serif;font-size:14px'>Just click on the following link to validate your email.</span><a href='http://www.example.com/validate.php?username=$username'  target='blank'>Validate</a></div></body></html>";       

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.