Page 1 of 1
Inserting link into email problem
Posted: Wed Jun 22, 2011 11:57 pm
by newphper
Hello Internet,
Can anyone work out why my bit of code here wont work for me ?
I am having a problem working out why the second lot works and the first part doesn't.
The link "
http://www.mywebsite.com.au" works
The link "event_booking_new.php?events_id=";
$mesg .= $event_id; DOES NOT WORK…..
Code: Select all
$mesg .= $event_address;
$mesg .= "\n\n";
$mesg .= $invite_extra_text;
$mesg .= "\n\nIf you would like to attend, click here to book in event_booking_new.php?events_id=";
$mesg .= $event_id;
$mesg .= ".\n\nCheck out our other upcoming events at http://www.mywebsite.com.au.
$mesg .= "\n\n";
$mesg .= $signature_first_line;
This code works….
Code: Select all
$mesg .= $event_details;
$mesg .= "<br><br>";
$mesg .= $invite_extra_text;
$mesg .= '<br><br>If you would like to attend, click here to <a HREF="http://www.mywebsite.com.au/event_booking_new.php?events_id=';
$mesg .= $event_id;
$mesg .= '">book in</a><br>Check out our other upcoming events at <a HREF="http://www.mywebsite.com.au">My Web Site</a>.';
$mesg .= "<br><br>";
$mesg .= $signature_first_line;
Re: Inserting link into email problem
Posted: Thu Jun 23, 2011 3:40 am
by Apollo
newphper wrote:The link "event_booking_new.php?events_id=";
$mesg .= $event_id; DOES NOT WORK…
That's not a complete
URI. Without <a>, no parser will recognize that as a clickable link.
Are you sure you don't want to include
http://some.domain.com/ in that address? (making it a local link within the same website)
And are you sure you don't even want to include a /path or something, making the .php link relative to whatever subdirectory the above page is located in?
Both of these shortcomings make the link completely useless in email.
Try this:
Code: Select all
$mesg = "http://your.website.com/the/correct/subdir/event_booking_new.php?events_id=".$event_id;
Or this:
Code: Select all
$mesg = "<a href='event_booking_new.php?events_id=$event_id'>click me plz!</a>";
Although the latter uses that incomplete address of yours, of which I doubt if that's what you actually intended.
Re: Inserting link into email problem
Posted: Thu Jun 23, 2011 7:17 pm
by newphper
Thanks for your advice Apollo, problem is I have tried your suggestion and I guess it may be a syntax error on my part.
I look after the website and have managed to figure out most issues, but not this one.
This is the code snippet, if you can solve the problem, we are happy to pay you for your effort, if you will take payment.
There are plenty of other email code sections that I can compare this to, this is in a html section and <br> is used instead of \n, I do not know why the programmer did that .........just curious and learning my way.
The lines ----------------- "If you would like to attend, click here to book in"event_booking_new.php?events_id=";
$mesg .= $event_id;
$mesg .= ".\n\n.... --------------needs to work.
Code: Select all
$mesg .= $event_address;
$mesg .= "\n\n";
$mesg .= $invite_extra_text;
$mesg .= "\n\nIf you would like to attend, click here to book in event_booking_new.php?events_id=";
$mesg .= $event_id;
$mesg .= ".\n\nCheck out our other upcoming events at http://www.mywebsite.com.au.
$mesg .= "\n\n";
$mesg .= $signature_first_line;
Re: Inserting link into email problem
Posted: Fri Jun 24, 2011 10:43 pm
by newphper
I managed to get it to work
This is what worked, don't get why it didn't need the A href stuff, but it works.
Code: Select all
$mesg .= "\n\nIf you would like to attend, click here to book in http://www.mywebsite.com.au/event_booking_new.php?events_id=";
$mesg .= $event_id;
Re: Inserting link into email problem
Posted: Sat Jun 25, 2011 3:05 am
by Apollo
It's because you now inserted
http://your.website.com/... in front of the script address, so now you have a complete, correctly formatted URL. See also my previous post.
Re: Inserting link into email problem
Posted: Sun Jun 26, 2011 6:33 pm
by newphper
What I do not yet understand is why it works in that piece of code...
To make it work elsewhere in the same file...(there are numerous email mailouts) the <a href ...</a> element needed to be used.
The email piece of code before that one has the <a href ...</a> element used in it.
Can anyone explain the reason for that please ?
Re: Inserting link into email problem
Posted: Mon Jun 27, 2011 3:24 am
by Apollo
It's because you're viewing that message in a client (website or local program) that automatically converts anything like www
.example.com
/script.php into a clickable link.
This forum does the same. If I literally insert that exact same example address here normally (the one above was posted with funky trickery), the forum turns it into:
www.example.com/script.php
Re: Inserting link into email problem
Posted: Wed Jun 29, 2011 3:59 pm
by newphper
Ok, thanks for explaining.
I am basically learning "on the job" and I have to be very careful I don't "break" the live website............
I have a few coding jobs that are a bit much for me, is anyone on this forum qualified enough to do a bit of casual paid work on an established website ?
Some extra fields need to added to the database(have done that), some extra input fields on the current join online form(have done the code)
If anyone is interested and can do the job, please send me an email with ur phone number and I will call you.