Looking for a quick fix in PHP script -- Should be simple

Discussion in 'PHP' started by RNK Concepts, Dec 9, 2008.

  1. #1
    Hello everyone!

    I am curious as to how I can echo a variable in this line of code:

    // Body
        $mailer->Body = 'Thank you for purchasing my Product<br /> Please follow this link: <a href="#">Link Text</a> to complete the registration process.';
    Code (markup):
    I need to echo a value as the link.

    for instance:

    // Body
        $mailer->Body = 'Thank you for purchasing my Product<br /> Please follow this link: <a href="echo $emailaddress">Link Text</a> to complete the registration process.';
    Code (markup):
    I know the syntax is wrong, and I'm wondering if anyone can help me by either letting me know how to fix it, or if there is a link to some info out there, either would be appreciated.

    Thanks!
     
    RNK Concepts, Dec 9, 2008 IP
  2. firman01

    firman01 Well-Known Member

    Messages:
    155
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    165
    #2
    $mailer->Body = 'Thank you for purchasing my Product<br /> Please follow this link: <a href="echo $emailaddress">Link Text</a> to complete the registration process.';

    to

    $mailer->Body = 'Thank you for purchasing my Product<br /> Please follow this link: <a href="'.$emailaddress.'">Link Text</a> to complete the registration process.';
     
    firman01, Dec 9, 2008 IP
  3. RNK Concepts

    RNK Concepts Peon

    Messages:
    74
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Awesome firman01, I'll try that ... Thanks!
     
    RNK Concepts, Dec 9, 2008 IP
  4. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #4
    Either this

    $mailer->Body = 'Thank you for purchasing my Product<br /> Please follow this link: <a href="'.$emailaddress.'">Link Text</a> to complete the registration process.';

    or

    $mailer->Body = "Thank you for purchasing my Product<br /> Please follow this link: <a href=\"$emailaddress\">Link Text</a> to complete the registration process.";
     
    ads2help, Dec 9, 2008 IP
  5. RNK Concepts

    RNK Concepts Peon

    Messages:
    74
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hey all,

    I appreciate the help with the previous issue, however, now I have the problem with the script not sending a message ... Can anyone help?

    Here's the code:

    <?php
    $product = "BreakTest-2 MM";
    $mastermind_link = "Link URL";
    $emailaddress = $_POST['email1'];
    $name = $_POST['name'];
    
    if (isset($_POST['product2']) && $_POST['product2'] == $product) { 	//Bundle is being purchased
    
    	header('Location:' .$mastermind_link);
    	$send_signup = true;
    
    } 
    else {
    
        header('Location: http://URL');
    
    }
    
    if ($send_signup) {
    	
    	require_once($_SERVER['DOCUMENT_ROOT'].'/config.php');
     
    	require_once($_SERVER['DOCUMENT_ROOT'].'/lib/MailClass.inc');
     
    	$mailer = new AutoMailer();
     
    	// Set the subject
    	$mailer->Subject = 'My Subject';
     
    	// Body
    	$mailer->Body = 'Thank you for purchasing my Product<br /> Please follow this link: <a href="'.$mastermind_link.'">Mastermind Sign-up</a> to complete the registration process.';
     
    	// Add an address to send to.
    	$mailer->AddAddress($emailaddress, $name);
    } 
    
    if(!$mailer->Send()) {
        echo 'Confirmation email was not sent. Please contact the site administrator to resolve the issue.';
    }
    
    $mailer->ClearAddresses();
    $mailer->ClearAttachments();
    
    ?>
    Code (markup):
     
    RNK Concepts, Dec 9, 2008 IP
  6. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #6
    You need to use double quote to put variables in string literals.

    $mailer->Body = "Thank you for purchasing my Product<br /> Please follow this link: <a href=\"{$emailaddress}\">Link Text</a> to complete the registration process.";
    PHP:
     
    Kaizoku, Dec 10, 2008 IP