#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0

    Html url in php variable


    $greeting = 'Thank you for registering with Shadow Web Design. You can now <a href="login.php">Login</a> to your account.';

    Hi, I have added the above in to my php code and its coming back as not liking it due to the "".

    Can anyone help me with this one as to where it's falling short.

    The idea is that after someone registers, they receive an automated e-mail welcoming them to the site which works fine. I now want to add in the url for the Login but this is failing.

    any ideas as to why and how it should be set out?
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,920
    Rep Power
    1045
    Hi,

    using double quotes in single quoted strings (and vice versa) is absolutely valid. So whatever problems you experience, they have nothing to do with the quotes.

    Give us the full code and a concrete error description (including all error messages), then we might be able to help you.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0
    code:
    $greeting = 'Thank you for registering with Shadow Web Design. You can now <a href="login.php">Login</a> to your account.';

    $to = $email;
    $from = "admin@[hidden from forum].co.uk";
    $subject = "Member Registration";
    $message = "Name: " . $name . "\nEmail: " . $email . "\nUserID: " . $userid . "\nPassword: [not provided for security] " .
    "\nThank you for registering with [company name hidden from forum]. You can now " . $greeting";

    ****************

    PHP Error Message

    Parse error: syntax error, unexpected '"' in /home/a4649813/public_html/php/register/process.php on line 18

    ****************
    Line 18 is: $greeting = 'Thank you for registering with Shadow Web Design. You can now <a href="login.php">Login</a> to your account.';
  6. #4
  7. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,920
    Rep Power
    1045
    Are you sure that's the line? I'm getting this exact error in the last line
    PHP Code:
    "\nThank you for registering with [company name hidden from forum]. You can now " $greeting"; 
    because of the double quote after $greeting.

    But of course there could also be another error in the code before line 18 (which we can't check).
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0
    $message = "Name: " . $name . "\nEmail: " . $email . "\nUserID: " . $userid . "\nPassword: [not provided for security] "
    . "\n\nThank you for registering with Shadow Web Design. You can now <a href=\"login.php\">Login</a> to your account";

    ****
    I have decided to get rid of the variable and do it via the above method instead. The e-mail is delivered however it displays as below:
    ****
    Name: [not provided for security]
    Email: [not provided for security]
    UserID: [not provided for security]
    Password: [not provided for security]

    Thank you for registering with Shadow Web Design. You can now <a href="login.php">Login</a> to your account

    ****
    As you can see, within the e-mail the whole text is displayed and is therefore not a clickable link...
  10. #6
  11. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,920
    Rep Power
    1045
    Originally Posted by shadowwebs
    As you can see, within the e-mail the whole text is displayed and is therefore not a clickable link...
    Then it's a plaintext mail and not an HTML mail. I guess you're using the mail() function? Use a mail library like PHPMailer instead. Sending HTML mails through mail() is pretty cumbersome, because you have to manually set the mail headers.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0
    give this a shot:

    PHP Code:
    $headers  "MIME-Version: 1.0\nContent-Type: text/html; charset=iso-8859-1\n";
    $headers .= "From: emailaddress\r\n";
    $headers .= "Reply-To: emailaddress\r\n";

    mail('emailaddress'$subjectnl2br($message), $headers); 

IMN logo majestic logo threadwatch logo seochat tools logo