Forum Moderators: coopster

Message Too Old, No Replies

Allow & in form submission

         

subtilty

11:28 am on Oct 18, 2007 (gmt 0)

10+ Year Member



Hi Guys,

My first post here and I am still learning PHP so bare with me

I have a html form that submits to a php script which prints out the results into an email ready to send.

However if someone uses an Ampersand (&) in a company for example AT&T the script stops after the &.

Could you help me on how to change the script so it allows the character to de displayed and completes the script correctly?

Thanks Guys!

James

If you would like to see the script its <snip>
Add a company name with a & and when you click on mail it doesnt work

[edited by: dreamcatcher at 6:16 pm (utc) on Oct. 18, 2007]
[edit reason] no urls as per T.O.S [webmasterworld.com].Thanks [/edit]

deMorte

11:40 am on Oct 18, 2007 (gmt 0)

10+ Year Member



I can't say I know why your script does that (probably has something to do with the mailing functions), I'm not too great on PHP myself, but here is a suggestion how to change the & to something different:

Use str_replace -function on the texts. As such:


str_replace("&", "&amp;", $string);

PHP_Chimp

11:57 am on Oct 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When you say that everything after the & is not there, in what is it not there?

Is your AT&T becoming AT& in the $_POST['company'], or in the email that you are receiving? If it is wrong in the email, is it an html email or plan text?

You could use the idea above to change '&' to 'and' as there should be no encoding issues with the word and, however using &amp; in plain text will not help you...as only those that speak html will get &amp; = & :)

subtilty

12:58 pm on Oct 18, 2007 (gmt 0)

10+ Year Member



Thanks for your replies.

I managed to do it in the end by using urlencode($company)