Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Mar 2003
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    send to a friend help

    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

    Code:
    <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

    Code:
    <?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);
    }?>

  • #2
    Regular Coder Tyree's Avatar
    Join Date
    Sep 2003
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!

  • #3
    New Coder
    Join Date
    Mar 2003
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    that isnt the problem it send fine, the problem is that it doesnt sent the page url

  • #4
    Regular Coder Tyree's Avatar
    Join Date
    Sep 2003
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #5
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,092
    Thanks
    2
    Thanked 322 Times in 314 Posts
    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.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #6
    New Coder
    Join Date
    Mar 2003
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    So is there another way of doing it that is reliable?

  • #7
    Regular Coder Tyree's Avatar
    Join Date
    Sep 2003
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If it's always going to be sent from the same site, you could prefix $PHP_SELF with the default path.

  • #8
    New Coder
    Join Date
    Mar 2003
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    same site different URL

    example1
    www.XXXX.com/article01.htm

    example2
    www.XXXX.com/article02.htm

    and so on

  • #9
    Regular Coder Tyree's Avatar
    Join Date
    Sep 2003
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mrdeleigh View Post
    same site different URL

    example1
    www.XXXX.com/article01.htm

    example2
    www.XXXX.com/article02.htm

    and so on
    Right.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •