1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to get a Clickable Link inside this text string?

Discussion in 'PHP' started by Panda123, Oct 1, 2016.

  1. #1
    The code below is from a simple PHP script that sends a test email.
    How can I get a clickable link inside this text based message string?
    Note: My Page is going to be the clickable link.

    $message = "Please Click on the link here: My Page";
     
    Last edited: Oct 1, 2016
    Panda123, Oct 1, 2016 IP
  2. Einheijar

    Einheijar Well-Known Member

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    3
    Trophy Points:
    165
    #2
    <a href='mypage.html'>My Page</a>
    Code (markup):
    Not quite sure why this is a PHP question, should be more into a basic HTML question.
     
    Einheijar, Oct 2, 2016 IP
  3. Panda123

    Panda123 Active Member

    Messages:
    43
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    63
    #3
    Sorry I didn't clarify.....When I run the php email script it sends me the code
    <a href='mypage.html'>My Page</a>
    Code (markup):
    and not the link.

    Regards, Panda123
     
    Panda123, Oct 3, 2016 IP
  4. Einheijar

    Einheijar Well-Known Member

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    3
    Trophy Points:
    165
    #4
    
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
    
    // More headers
    $headers .= 'From: <webmaster@example.com>' . "\r\n";
    $headers .= 'Cc: myboss@example.com' . "\r\n";
    
    mail($to,$subject,$message,$headers);
    
    Code (php):
    You forgot to set the MIME headers for the email
     
    Einheijar, Oct 3, 2016 IP
  5. Panda123

    Panda123 Active Member

    Messages:
    43
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    63
    #5
    Hi Einheijar, thanks for the reply!

    I changed the headers to exactly what you had and I still get a text email with the code and not an html email with the link.

    Here is a generic version of the code I'm using without my info. Just generic info:

    <?php
    $msg="";
    if(isset($_POST['submit']))
    {
        $from_add = "support@XXXXXXXXXX.com";
        $to_add = "support@XXXXXXXXXX.com";
    
        $subject = "Test Subject";
       
        $message = "Test Email Message - Click Here: <a href='https://www.google.com'>Test</a>";
           
        $headers = "MIME-Version: 1.0" . "\r\n";
        $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
        //$headers  = 'MIME-Version: 1.0' . "\r\n";
        //$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        $headers = "From: $from_add \r\n";
        $headers .= "Reply-To: $from_add \r\n";
        $headers .= "Return-Path: $from_add\r\n";
        $headers .= "X-Mailer: PHP \r\n";
       
       
        if(mail($to_add,$subject,$message,$headers))
        {
            $msg = "Mail sent OK";
        }
        else
        {
            $msg = "Error sending email!";
        }
    }
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
        <title>Test form to email</title>
    </head>
    
    <body>
    <?php echo $msg ?>
    <p>
    <form action='<?php echo htmlentities($_SERVER['PHP_SELF']); ?>' method='post'>
    <input type='submit' name='submit' value='Submit'>
    </form>
    </p>
    
    </body>
    </html>
    Code (markup):
     
    Panda123, Oct 5, 2016 IP
  6. pagecoder

    pagecoder Banned

    Messages:
    61
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    45
    #6
    on line # 16 you are missing a dot that is overwriting the $headers.
    instead of $headers ="From: $from_add \r\n"
    use $headers.="From:$from_add \r\n"
     
    pagecoder, Oct 5, 2016 IP