View Full Version : Hyperlink in PHP Form
rosschapman
November 21st, 2007, 21:08
How do I make he included address into a hyperlink? Putting <a href round it screws the php.
I currently have:
$copy_intro[0]="Thanks for your inquiry, please download our PDF from the following link:<br /><br />http://www.domain.co.uk/download.pdf";
thanks in advance,
chaos
November 22nd, 2007, 00:36
Putting <a href round it screws the php.
Screws it how? I don't think there is any other way than to use the anchor tag. The real trick with PHP is remembering that you have to be careful with the quotation marks. Use the single quotations, or use escape \'s. Is this what you're asking?
http://www.hostingfanatic.com/webdev/php/101/faq/quotes-in-string.html
Something like:
echo "<a href='$url'>$url</a>";
I didn't check the code itself, but something like that should work...
rosschapman
November 22nd, 2007, 00:53
Like this?
$copy_subject[0]="PDF Download";
$copy_intro[0]="Thanks for your inquiry, please download our PDF from the following link:<br /><br />
echo "<a href='http://www.domain.co.uk/download.pdf'>http://www.domain.co.uk/download.pdf</a>";
$copy_from[0]="email@address.com";
That gives me a Parse error: syntax error, unexpected T_STRING in ....
chaos
November 22nd, 2007, 01:04
Sorry, I must not have been very clear :oops: "Echo" is a PHP command used for printing to screen. I was merely using it as an example, but I forgot to say what that example would do :-)
The following is correct:
<?PHP
//This is what you're concerned with right here :-)
$copy_subject[0]="PDF Download";
$copy_intro[0]="Thanks for your inquiry, please download our PDF from the following link:<br /><br /><a href='http://www.domain.co.uk/download.pdf'>http://www.domain.co.uk/download.pdf</a>";
$copy_from[0]="email@address.com";
//The following code is merely to demonstrate what exactly has been stored and how. This simply takes all the variables and sends them via HTTP to the browser. I added a few "<br/>" to pretty up the output :)
echo $copy_subject[0];
echo "<br />";
echo $copy_intro[0];
echo "<br />";
echo $copy_from[0];
?>
This code will return the following:
http://w3wizardry.com/projects/new.php
Edit:
I presume this is for a premade Form mailer script? Hence the variable names like:
"copy_intro[0]"
rosschapman
November 22nd, 2007, 01:09
Fantastic - it's alive!
Thanks for your help Chaos!
chaos
November 22nd, 2007, 01:12
Yay! I'm glad that worked.
By the way... I was looking at your portfolio site, and I must say that you've got some fine work in there :) Nice job.
deathshadow
November 22nd, 2007, 06:13
I would suggest inverting those quotes for consistancy - AND execution speed. Single quotes in php (and most other languages) mean don't parse for escape codes and vars, while double quotes mean parse. Parsing takes extra time and shouldn't be set up to use unless you need it.
So, unless you need to inline declare a variable (there's no reason to do that since you can just close commma comma open) or use escape codes like /n or /t - there's no reason to use double quotes... AND it means your HTML looks more 'standard'.
Based on your example, I'd be using this:
$copy_intro[0]='
Thanks for your inquiry, please download our PDF from the
following link:<br />
<br />
<a href="http://www.domain.co.uk/download.pdf">download.pdf</a>
';
chaos
November 22nd, 2007, 06:18
That's pretty cool! Thanks for the tip. I honestly never thought about using a single quotation mark at the beginning...
<<goes to change my various other PHP projects>>
vBulletin® v3.6.8, Copyright ©2000-2012, Jelsoft Enterprises Ltd.