开发者

HTML email from PHP - apostrophe problem

开发者 https://www.devze.com 2023-03-28 11:52 出处:网络
I have a webform in php that sends 2 emails.One is in plaintext, one in html to the customer that includes a url string based on the user input.

I have a webform in php that sends 2 emails. One is in plaintext, one in html to the customer that includes a url string based on the user input.

If the name field for instance says "Bob O'Reilly", the plaintext email is fine but the html email string would read "http://www.mysite.com?name=bob o", completely truncating the string. I know I nee开发者_Python百科d to escape the apostrophe but I've tried addslashes and it doesn't seem to do what I need it to.

Thanks


You should probably urlencode the string when using it in a link: http://php.net/manual/en/function.urlencode.php.

This transforms any characters that may have some special meaning to a code like %20 (space). You can use urldecode if you need to accept a requested, urlencoded string.

0

精彩评论

暂无评论...
验证码 换一张
取 消