Page 1 of 1

Small link problem (printing from script to email)

Posted: Wed Feb 10, 2010 3:53 pm
by MiniMonty
Hi all,

I have a script which grabs some variables then sends an email with a link and it all works fine
except for one annoying detail. I have a varibale "$courseName" which (guess what) holds he name of a course.
That name is always three or four words long i.e. "Tune In To Programs".
In the code below you'll notice the "print $linkToSend" - this prints the whole big link with the WHOLE course name,
but when the email arrives, the text is all printed as a link but only the first word of the course name is part of the link. Like this:

Image

When clicked, this causes the page that the third party sees to display badly (wrong course name) so I'm wondering where I've gone wrong ?
All and any advice much appreciated.

Best wishes
Monty

My code to build the "$linkToSend" and send the email is this:

Code: Select all

 
$linkToSend = "http://www.SomeDomain.com/critique.php?student_id=".$id."&course_num=".$sub_course_num. "&courseName=" .$courseName;
print $linkToSend;
 
  ///////////  now send the email     
              
    $to = "$tutor_email";                                        
    $from = "admin@SomeDomain.com";
    $subject = "Critique Required";
    //Begin HTML Email Message
    $message = "Hi $tutorFirstname,
 
   A student on your course $courseName has uploaded their coursework and now requires a critique.
   Please view their work by following this link:
   $linkToSend
 
   admin@SomeDomain.com";
   //end of message
   
    $headers  = "From: $from\r\n";
    $headers .= "Content-type: text\r\n";
 
    mail($to, $subject, $message, $headers);
 

Re: Small link problem (printing from script to email)

Posted: Thu Feb 11, 2010 1:21 am
by rahulzatakia
Hi Monty,

Just replace the space in $courseName variable with '%20' and then pass the variable to the link...
Then it should work fine.