PHP Special Character
Actually, there is just that. http://nl3.php.net/manual/en/function.htmlentities.php
Thank you :)
Rather than opening a new thread I'll ask my next questoin here too..
When getting user input, from a form for example, and writing that to a file.. I get \' all the time rather than ' .. and the same with other special characters. I'm guessing there's a really simple way to avoid this that I've missed, is there?
Thanks yet again
x_5631 wrote: My only problem now is, that I'm printing the file with HTML characters stripped and for some reason, it's ignoring linebreaks. My solution to this before was to use <br> but because I need <br> and such to be printed I can't use that. Any ideas?
So, you're printing the contents of a file instead of the contents of a webpage. In that case, you're not working with HTML conventions… you're working with ASCII conventions. This should help:
Google will find you a good ASCII chart (every programmer should have one of these handy) but, for what you need, you currently only need the ASCII code for a line break: 13.
Ok, thanks I'll give that a try.. although I'm not sure how I should use that because the file does conatin linebreaks already, it's just not outputting them.
I'll try readline I suppose, and append the (chr(13)) to the end of each line.
Now, if I get input from a form and I want to change it before it's submitted (using GET method) is there any way I can do that? I thought it might be possible in JavaScript. Example:
<form name="formone" action="mypage.php" method="GET"> <input type=text value="" name="textbox1"><br> <input type="submit" value="Submit"> </form>
and I want to change what's sent as the value "textbox1" when the user clicks the submit button.
Thanks again, and sorry for asking so many questions.
I need to change it before it's submitted to the PHP page.. for some reason it just doesn't load anything when there are certain things in the url because of the $_GET value, so I figured if I can convert it to something else before submitting it, then do the opposite on the PHP page where it's being used. So yeah I was aiming at using JavaScript but I wasn't sure if it could be done easily.
Okay I fixed it using the following javascript:
{
st = frm1.cont1.value;
st = st.replace(/\"/g, "SPC_2");
st = st.replace(/\'/g, "SPC_3");
st = st.replace(/\n/g, "SPC_4");
frm1.cont2.value = st;
btn1 = document.getElementById("sbm");
btn1.click();
}```
and then on the PHP page that prints the file, I did the opposite replacements.
Thanks to everyone who helped for that help.