Okay, I’m further refining my invite system, thanks to all who have helped thus far! Now there is a small issue, what do I do if there is a space in the variable link? Like below:
Just use the URL… No encoding needed. You only need to encode it if you are sending special characters.
It should work as-is without any encoding. If for some odd reason you think you need to add encoding, you can use the first version using the rawurlencode() function, but, it is NOT needed.
How are you putting this into your email? Are you sending a plain-text email or a full html-email. These days everyone uses html-email. Therefore, you need to create a link in the email using an “anchor”. This will include the “HREF” which would be your URL. BUT, you need to “ESCAPE” the special characters like quotes… Here is a way around that. Just put the link right into the URL when you create it.
Something like this:
$Url = "<a href='https://somedomain.net/core/index.php?email2=\"[email protected]\"&user=\"Frank Bob
"'>Text for reader to see in email...</a>";
Notes: To create a URL LINK in an email, you need to echo it in PHP to the email. But, then, the quotes inside of other quotes need to be ESCAPED. BUT, only if the outer quotes are used again inside the string. This means that if you use DOUBLE-QUOTES at beginning and end of the PHP variable creation, you do not need to escape SINGLE-QUOTES. BUT, you do need to escape DOUBLE-QUOTES inside of other DOUBLE-QUOTES. This is to prevent the outer-and-ending DOUBLE-QUOTES from ending the string before you are finished. Hope that makes sense. Once you create that, you can just echo the $Url variable inside the email wherever you want it.
I realize this can be confusing. Many many people have had issues with quotes inside of other quotes. Something it gets very tricky to sort them out. This one is easy!
And then this is sent as an e-mail to those invited. So the $who2 var needs to be able to handle spaces, because the receiver clicks the link to proceed to the next step (thus passing the vars to the second PHP page).
But, again, this is just a value for the URL, not the link. Where do you place the $message variable into the email? You might need to change that too…
Also, the link needs to be just a text URL, not contained in HTML. It seems to work better for my purposes. However, I can’t get your example to work tho. Can you please show me again without the markup? Also, the email2 var is “$link” which contains the submitted e-mail.
The $message you showed is just text. Therefore inside an email it would just be simple text, too.
If an email is sent out from your mail server, it can be just text or HTML formatted. Most all are HTML now.
But, if the $message is being sent out as a text, links work differently. Either way, you need the ending
results to have quotes or double quotes around the values. In the last post I simply added single-quotes
around the values. This should work as long as the $message variable is not sent inside other quotes.
Does that help explain it?
How are you sending out the email? With PHP’s mail() function? If so, this version will work for you.
Well, as you see it is inside quotes. So, try this instead:
$message = "Proceed to this secure link to continue: " . $url;
Note that this ADDs or CONCATENATEs the $url variable to the end of the $message variable.
It does not INSERT it into the text stream. I think that explains it. Just add to it not insert it.