...

View Full Version : send to a friend help



mrdeleigh
11-29-2006, 04:52 PM
Hi
Having trouble with the below code, Its ment to send the url of the page the html is on but its not, can anyone see why?

thanks

html


<form action="somepage.php" method="post">
One Email per line<br>
<textarea name="emails"></textarea><br>
<input type="submit" name="submit" value="Send">
</form>


php


<?php
$email1 = explode("\n",$_POST['emails']);
foreach($email1 as $emailaddr){
$email = $emailaddr;
$subject = "This Is Your Subject Line";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: ".$_POST['name']." \r\n" . "X-Mailer: PHP/" . phpversion();

$message = '<p>This is your message it can have HTML in it</p>
<p><a href="'.$_SERVER['HTTP_REFERER'].'">This Site</a></p>';
$mail = mail($email, $subject, $message, $headers);
}?>

Tyree
11-29-2006, 05:26 PM
I'm not a php guru by any means...but...

It looks like you've defined the variable $mail as the mail function, but you haven't done anything with it.

Axe the "$mail = " part and it should send.

Later!

mrdeleigh
11-29-2006, 06:31 PM
that isnt the problem it send fine, the problem is that it doesnt sent the page url

Tyree
11-29-2006, 07:05 PM
I'm testing it on my server. Your code works fine.

One thing I changed was for the action for the form to be <?php print $PHP_SELF ?>. I know you're not using "somepage.php", but are you using the current page to process the form?

CFMaBiSmAd
11-29-2006, 07:14 PM
HTTP_REFERER is optional. Depending on your browser, browser version, or browser settings it is not set. In short, you cannot rely on HTTP_REFERER to be set and if it is set, you cannot rely on the value in it. For example, I could remotely call your script using a script and set HTTP_REFERER to be my site and your mail server would send it.

mrdeleigh
11-29-2006, 07:16 PM
So is there another way of doing it that is reliable?

Tyree
11-29-2006, 07:20 PM
If it's always going to be sent from the same site, you could prefix $PHP_SELF with the default path.

mrdeleigh
11-29-2006, 07:24 PM
same site different URL

example1
www.XXXX.com/article01.htm

example2
www.XXXX.com/article02.htm

and so on

Tyree
11-29-2006, 07:27 PM
same site different URL

example1
www.XXXX.com/article01.htm

example2
www.XXXX.com/article02.htm

and so on

Right.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum