I’ve got a form and I want to send the data to an email which the user can then check before sending. I’ve got the results in $body but when I try and put that into an email link I just get $body in the email rather than what var_dump($body); shows it should be.
This is the code I’m using:
header("Location: mailto:email@address.com?Subject=New message from website&body=$body");
Thanks that worked but only if the message didn’t have too many spaces, I think I need to do what droopsnoot suggested and use url-encode but how do I do that?
Replace the spaces with %20
With double quotes like you had originally, you should not need to exit them to insert a variable, so I’m not sure why that did not work. Maybe because it’s on the end of the string it is best to close the quotes anyway, you should not need to open and close them again after the variable.
A quick search suggests you should use rawurlencode() instead of urlencode(), as the latter will convert spaces to plus signs, and the former will not.
I appreciate that but didn’t know any other options as the script I was using has stopped working and the client doesn’t want to speak to her hosts about any updates they’ve done so asked me to do it like this.
I’ve checked through the script and there’s no problems with the actual script - everything is output properly and as it should do but nothing is ever received from it.
I would think so, they’re just alternatives to using the PHP mail() function. If the old script is suddenly not working, you mentioned that the owner didn’t want to talk to the host about updates, do you have any idea of what the updates might be? Or you could post the script code here, anonymised of course, to see if anyone can spot what’s going wrong.