Jump to content

Link in PHP


Jasper99

Recommended Posts

Seeing as it's pretty much the most basic thing you can do I suspect you either don't know html, or php.

(Can't imagine anyone not knowing html while knowing php though).

 

So you may want to start off with reading some tutorials first, w3schools has excellent tutorials on html and php.

Link to comment
https://forums.phpfreaks.com/topic/152937-link-in-php/#findComment-803214
Share on other sites

My be the problem is not soooo basic.

It still do not work. 

My problem:  It is a newsletter with a 'tell to a friend' option.  After filling out a 'tell to a friend' form an email is send to the 'friend' and it should show the link to the newsletter.  What can I do that the link will be shown in the email?  As I said the basic script is php.

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/152937-link-in-php/#findComment-803225
Share on other sites

Here it is out of the garage. 

 

Here's the script (tellafriend.php):

 

<?php
if(count($_POST)) {

foreach(array('fmail1','fmail2','fmail3','email','name') as $key) $_POST[$key] = strip_tags($_POST[$key]);
if(!is_secure($_POST)) { die("Hackers begone");}

$emailto = "[email protected]"; 

$esubject = "Recommendation form submission"; 

$emailtext = "
$_POST[name] has used your recommendation form using an email address of $_POST[email]

The people the recommendation has been submitted to are:

$_POST[fmail1]
$_POST[fmail2]
$_POST[fmail3]

The page recommended:

$_POST[refurl]

";

@mail("$emailto", $esubject, $emailtext, "From: $_POST[email]");

$thankyoupage = "thankyou.htm"; 



$tsubject = "A web page recommendation from $_POST[name]";

$ttext = "
Hi,

$_POST[name], whose email address is $_POST[email] thought you may be interested in this web page. 

$_POST[refurl]

$_POST[name] has used our Tell-a-Friend form to send you this note.

We look forward to your visit!

";

@mail("$_POST[fmail1],$_POST[fmail2],$_POST[fmail3]", $tsubject, $ttext, "FROM: $_POST[email]");

# After submission, the thank you page
header("Location: $thankyoupage");
exit;

}

function is_secure($ar) {
$reg = "/(Content-Type|Bcc|MIME-Version|Content-Transfer-Encoding)/i";
if(!is_array($ar)) { return preg_match($reg,$ar);}
$incoming = array_values_recursive($ar);
foreach($incoming as $k=>$v) if(preg_match($reg,$v)) return false;
return true;
}

function array_values_recursive($array) {
$arrayValues = array();
foreach ($array as $key=>$value) {
if (is_scalar($value) || is_resource($value)) {
$arrayValues[] = $value;
$arrayValues[] = $key;
}
elseif (is_array($value)) {
$arrayValues[] = $key;
$arrayValues = array_merge($arrayValues, array_values_recursive($value));
}
}
return $arrayValues;
}

?>

 

Where the code is $_POST[refurl] should be shown the link:

 

The page recommended:

$_POST[refurl]

 

and

 

$_POST[name], whose email address is $_POST[email] thought you may be interested in this web page. 

$_POST[refurl]

$_POST[name] has used our Tell-a-Friend form to send you this note.

 

Hope you can help me.  Thanks.

Link to comment
https://forums.phpfreaks.com/topic/152937-link-in-php/#findComment-803238
Share on other sites

You're wanting the link to appear as a link in an email?

 

Depends on how the client picks it up and translates the body - some will show the link as a link others will show it as text because you're sending a plain text email using PHP's mail() function.

 

A better way would be to download and install the great free PHPMailer script and send a proper HTML email.

 

I've actually stopped using PHP's mail() function and now use PHPMailer instead.

 

http://phpmailer.codeworxtech.com/

Link to comment
https://forums.phpfreaks.com/topic/152937-link-in-php/#findComment-803244
Share on other sites

Yes, it is an email and not a Webpage, sure.

But in the code below it shows a link in the email (or at least the link as text).

 

The people the recommendation has been submitted to are:

$_POST[fmail1]
$_POST[fmail2]
$_POST[fmail3]

 

So it must be possible to show the link.  It don't have to be a variable.  I can change the code for each newsletter.

What do you think?

 

 

Link to comment
https://forums.phpfreaks.com/topic/152937-link-in-php/#findComment-803260
Share on other sites

Hi jasper

 

 

<?php
$emailtext = "
$_POST[name] has used your recommendation form using an email address of $_POST[email]

The people the recommendation has been submitted to are:

$_POST[fmail1]
$_POST[fmail2]
$_POST[fmail3]

The page recommended:
// if its url like domain.com than
<a href='$_POST[refurl]'>$_POST[refurl]</a>
// else if url like  <a href='link'>domain</a>
$_POST[refurl]

";

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'From: '$_POST[email]' . "\r\n";

@mail($emailto, $esubject, $emailtext, $headers);
?>

Link to comment
https://forums.phpfreaks.com/topic/152937-link-in-php/#findComment-804486
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.