dombrorj Posted February 2, 2011 Share Posted February 2, 2011 Hi, I'm trying to do the following: $name = $_GET['thename']; $to = "some@email.com"; $subject = "Subject of Email"; $message = "Click this link: http://mysite.com?$name" $headers = "From: Me" . "\r\n" . "Reply-To: my@email.com" . "\r\n" . "X-Mailer: PHP/" . phpversion(); mail($to, $subject, $message, $headers); The problem I'm experiencing is that the Get function retrieves "/thename=First+Last name", which converts to a broken link in the message (because of the "+" in the url). How would I use urlencode to make sure the Get replaces the + with a %20 in this instance? It doesn't seem that I can use php in the message itself. Thanks! Quote Link to comment Share on other sites More sharing options...
ChemicalBliss Posted February 2, 2011 Share Posted February 2, 2011 You need to use concatenation, but also the variable should only be the actual value of the get request item; $name = $_GET['thename']; // gets First+Last name $to = "some@email.com"; $subject = "Subject of Email"; $message = "Click this link: http://mysite.com?/thename=".urlencode($name); hope this helps Quote Link to comment Share on other sites More sharing options...
dombrorj Posted February 2, 2011 Author Share Posted February 2, 2011 Thanks for the help! I should have been more clear though on the message part, because there's more text after the link. I'ts more like: Click this link http://mysite.com?/thename=$name&var=$var2 more text... more text... Quote Link to comment Share on other sites More sharing options...
ChemicalBliss Posted February 2, 2011 Share Posted February 2, 2011 then since your making the variable _knowing_ that it is going to be used in a url (since it is formated for a header request), the values should be urlencoded() at the point of the strings creation. Quote Link to comment Share on other sites More sharing options...
dombrorj Posted February 2, 2011 Author Share Posted February 2, 2011 Hmmm... I wish I could do that but the values are passed by my merchant processor. Quote Link to comment Share on other sites More sharing options...
ChemicalBliss Posted February 3, 2011 Share Posted February 3, 2011 Then you will need to split the variable itnto its different parts. Can you confirm that this is what you get (Exactly)? /thename=First+Last name and not /?thename=First+Last name Quote Link to comment Share on other sites More sharing options...
dombrorj Posted February 3, 2011 Author Share Posted February 3, 2011 Thanks for all the help with this ChemicalBliss. The URL with the variables I want to Get is: /order-confirmation.php?item=136&reciept=6BB4B95E&thename=Dave+Test&cemail=test%40test.com&country=US&zip=90210 Quote Link to comment Share on other sites More sharing options...
dombrorj Posted February 3, 2011 Author Share Posted February 3, 2011 Got it... man I need to get past this learning curve! Just needed to add: $custname: urlencode($name); Then change all the $name instances to $custname. Thanks again for all your help! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.