I'm working in PHP - trying to parse the input of this form field:
"Enter as many email addresses as you want, separating with a single space."
However, I know users are stupid, so I need to be able to handle the input even if they separate with commas, commas and spaces, three spaces, etc. So I came up with the following statement:
$explodedAddresses = preg_split("/[\s,]+/", $allInvites);
Where $allInvites is the raw contents of the textarea from the form.
I then use the email addresses to build activation links for the recipients of the emails, which are in the following form -
/acceptInvite.php?email=example@test.com&code=xxxxxxxx - where code is their activation code, randomly generated 8 letter/number sequence.
The URL is then emailed to example@test.com
However - I'm having the following problem. Sometimes, and I can't determine what the pattern is, the first two letters of the email address (and sometimes the code) get cut off, along with the equals sign, leaving the link in the following form -
/acceptInvite.php?emailample@test.com&codexxxxxx
Here is the line of PHP that builds the link -
$link .= "\n\n /acceptInvite.php?email=$inviteMem->mem_email&code=$password \n\n";
What perplexes me however, is that the email gets delivered successfully, to the correct (non-truncated) address and I use the same variable to send the email as build the link. So my best guess is that it's some kind of character encoding issue? I really don't know. The PHP file is in "Western ASCII" encoding, with Unix line endings, on a Linux server.
Thanks for reading - any ideas? Let me know if you need more info.