Results 1 to 1 of 1

Thread: Recommend us to a friend - email takes friend to wrong page

  1. #1
    Steph84 Guest

    Recommend us to a friend - email takes friend to wrong page

    Hello - I know very little PHP/Javascript so I am having a problem that I hope is easily fixable.

    I installed a "recommend to a friend" tool to my website and have managed to solve a few issues I have had with it, however there is one issue I can't work out how to solve.

    The email that is sent to the 'friend' displays a link to the /siterecommender/recommend.popup.php page (that sent the email). I want it to take them to the home page instead.

    The php is as follows:

    PHP Code:
    $sitename '1-2-1 Music Tuition'// Name of your site.

    $url $_SERVER['HTTP_REFERER']; // Web address for your site.

    $webmasterEmail 'info@1-2-1music.co.uk'// Your email address.

    $receiveNotifications 1// 0=no, 1=yes. If yes, you will be notified of the recipients and the message.

    $errorstyleclass 'error'// The class that specifies the CSS error color.

    $numberofrecipients 4// Number of recipient email address fields to be displayed.

    $emailsubject 'Music tuition recommendation from [name] ([email])'//Email subject line.

    $emailmessage "Hello

    [name] thought you would like to visit the following site:

    [url]

    1-2-1 Music Tuition provide acoustic and electric guitar, bass guitar and drum tuition at competitive rates. They are based in a professional recording studio in Sheffield city centre. New pupils can get their first lesson for only £5. See their website for more information."
    // Message in email body. 

    $mailsent false
    $errormessages = array(); 
    $errorfields = array(); 

    if(
    count($_POST) > 0) { 
    if(
    get_magic_quotes_gpc()) $_POST strip_magic_quotes($_POST); 

    if(empty(
    $_POST['name'])) { 
    $errormessages[] = 'Please enter your name.'
    $errorfields[] = 'name'


    if(empty(
    $_POST['email'])) { 
    $errormessages[] = 'Please enter your email address.'
    $errorfields[] = 'email'
    } else { 
    if(!
    eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,3}$"$_POST['email'])) { 
    $errormessages[] = 'Please enter a proper email address for yourself.'
    $errorfields[] = 'email'



    for(
    $i=1$count=count($_POST['to']); $i<=$count$i++) { 
    if(empty(
    $_POST['to'][$i])) unset($_POST['to'][$i]); 


    if(empty(
    $_POST['to'])) { 
    $errormessages[] = 'Please enter at least one friend's email address.'; 
    $errorfields[] = '
    to[1]'; 
    } else { 
    foreach($_POST['
    to'] as $key=>$value) { 
    if(!empty($value)) { 
    if(!eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,3}$", $value)) { 
    $errormessages[] = '
    Please enter email address #' . $key . ' proper.'; 
    $errorfields[] = "to[$key]"





    // Now if there are no errors, send the message. 
    if(empty($errormessages)) { 
    $emailsubject str_replace('[name]'$_POST['name'], $emailsubject); 
    $emailsubject str_replace('[email]'$_POST['email'], $emailsubject); 
    $emailmessage str_replace('[name]'$_POST['name'], $emailmessage); 
    $emailmessage str_replace('[url]'$url$emailmessage); 
    $emailmessage .= "\r\n\n" 
    $_POST['message'] . 
    "\n\n\n\nNote: This message was not sent unsolicited. It was sent through a form located at $url. " 
    "If you believe this message was received on error, please disregard it."
    $emailheader "From: " $_POST['email'] . "\r\n" 
    "Reply-To: " $_POST['email'] . "\r\n" 
    "X-Mailer: GateQuest php Site Recommender\r\n"

    $sent = array(); 
    foreach(
    $_POST['to'] as $key=>$value) { 
    if(
    mail($value$emailsubject$emailmessage$emailheader)) { 
    $sent[] = $value


    $failed array_diff($_POST['to'], $sent); 
    $mailsent true

    if(
    $receiveNotifications) { 
    $subject 'Someone recommended your site'
    $message 'This is a message to tell you that ' $_POST['name'] . ' (' $_POST['email'] .')' 
    ' sent a website recommendation to ' implode(', '$sent) . 
    "\n\nMessage: " $_POST['message']; 
    $headers 'From: ' $webmasterEmail "\r\n" 
    'X-Mailer: GateQuest php Site Recommender'
    @
    mail($webmasterEmail$subject$message$headers); 




    ?> 
    (there is more code that follows but it is to do with the form that sends the email, not the email itself).

    It's clearly something to do with $url but beyond that I am not sure. How do I get the email to show a link to the home page, rather than the page that sent the email?

    Any help will be much appreciated.

    Thanks. Steph
    Last edited by Alan; 13 Sep 2010 at 05:10 AM. Reason: Changed colour to code.

Similar Threads

  1. Recommend Email Management Software or website
    By talon in forum General Questions
    Replies: 1
    Last Post: 10 Jun 2012, 10:05 PM
  2. How Can I Code an Easy and Quick Email Sign-Up for My Web Page
    By Speedy4946 in forum Web Design, HTML Reference and CSS
    Replies: 1
    Last Post: 06 Jan 2010, 10:20 AM
  3. email to a friend link?
    By dirksmith in forum General Questions
    Replies: 0
    Last Post: 25 Nov 2005, 04:45 AM

Posting Permissions

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