The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
PHP-General - Html url in php variable
Discuss Html url in php variable in the PHP Development forum on Dev Shed. Html url in php variable PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 28th, 2012, 05:19 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 3
Time spent in forums: 48 m 4 sec
Reputation Power: 0
|
|
|
PHP-General - 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?
|

November 28th, 2012, 05:26 AM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
|
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.
|

November 28th, 2012, 05:34 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 3
Time spent in forums: 48 m 4 sec
Reputation 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.';
|

November 28th, 2012, 05:47 AM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
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).
|

November 28th, 2012, 06:10 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 3
Time spent in forums: 48 m 4 sec
Reputation 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...
|

November 28th, 2012, 06:42 AM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
Quote: | 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.
|

November 28th, 2012, 02:09 PM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 3
Time spent in forums: 20 m 24 sec
Reputation 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', $subject, nl2br($message), $headers);
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|