Click to See Complete Forum and Search --> : Problem passing html thru url
norNerd
11-28-2009, 08:30 AM
Hi people, i got a sort of big problem, wich i actually think will be solved with just a little line of code either in html, javascript or php.
But i have no idea at all what i can do to solve it by my self.
So here it goes,
On my index.php i got four textareas, two is regular, the other two has WYSIWYG editors attached to it.
The two regular contains only:
My Name etc and Some other text the user wants to write.
The two with WYSIWYG editors attached are used to post images, and the form data as in the image is visually shown as a image, but behind the scenes in the WYSIWYG editor its like this:
<img src="" height="" width="" alt="" />
As in regular html code.
I _need_ to pass this once before saveing, and i must pass the html thru get function, or my whole script fails.
But when i pass it, it goes into urlencode i think, and it adds a little "%22" somewhere in my code that makes it look like this:
%3CIMG+src%3Dimages_dir%2Flady%2Fimage_url.jpg%22+width%3D154+height%3D140%3E%3CBR
And that makes it not working.
When i change the url to this:
%3CIMG+src%3Dimages_dir%2Flady%2Fimage_url.jpg+width%3D154+height%3D140%3E%3CBR
Then it works, so what i did was to remove the %22 after the image url.
Is there a way to remove the %22 automaticly for each submit of the get form, or is there another way to pass html thru get?
I'm up for using either PHP, HTML or JAVSCRIPT to solve this one.
Hope someone knows a slolution else then changeing form to post, as post will not make it work with the rest of my script.
norNerd
TheBearMay
11-28-2009, 11:15 AM
The %22 is a double quote ("), but if you can't find where you are inserting it you should be able to get rid of it using the string.replace() function in javascript. Before the urlencode assuming str contains the text string you are getting ready to send the code would look something like:
newStr=str.replace("\"","");
criterion9
11-28-2009, 11:49 AM
If you are possibly sending large amounts of data it would be much easier to use POST. Then you won't have to worry about url_encode or url_decode on the server-side at all.
donatello
11-28-2009, 07:38 PM
I use this:
$who = str_replace('/\%20/', ' ', $who); //This strips out the %20 you asked for
$who = ereg_replace("[-]", " ", $who); //This removes any dashes
$who = urldecode($who); //This will remove any + signs
donatello
11-28-2009, 07:40 PM
on another note, to replace any of those things to re-insert in your search string... you can do this:
$search = ereg_replace("[-]", " ", $search); // This will remove dashes
$search = urlencode($search); // This will encode the URL (replace spaces with + signs
norNerd
11-29-2009, 04:53 AM
Hi, thanks all for setting some ideas into my head..
I added this to my code
elseif($_GET['delete_img2']){
$content_name = $_GET['content0'];
$content_dag = str_replace("/\%22/", " ", $_GET['content1']);
$content_dag = urldecode($content_dag);
$content_dag = str_replace("<", "<", $content_dag);
$content_dag = str_replace(">", ">", $content_dag);
$content_natt = "";
$content_kladd = $_GET['content3'];
$postable = "true";
}
And now my problem is getting closer to be solved :)
<img src="%5C%22images_dir/lady/image_url.jpg%5C%22" width="154" height="140">
thats what i have now, so the html is sent
sucessfully, but im still not removing %22 and %5C showed up there to.
What can i do now ?
and thanks again :)
kris
norNerd
11-29-2009, 05:14 AM
I tried useing substr to remove some of the code, and a wird thing happend :s
//Added this to code:
$content_dag = substr($content_dag, 4, -4);
HTML before:
<img src="%5C%22images_dir/lady/image_url.jpg%5C%22" width="154" height="140">
HTML after:
src=\"produkter_org/man/produkter_man_level1.jpg\" width=\"150\" height=\"14
So as you see, this function wirdly removed the characters i wanted to remove, and it removed %5C%22, but it added slashes..
And ofcourse i cant show the image when <img and \"> is missing..
So cant use this in any tricky way can i?
Or wait, got a little idea while i wrote this, maybe i chould set <img and \">
as a default inside the elseif somewhere, then the only thing i need to do is echo/print the content of content_dag inside the <img and \> etc?
Or will this not work?
Might test it before someone replies but happy if someone helps :)
Kris
norNerd
11-29-2009, 05:28 AM
When adding <img and > in the echo/print
url turned out like this again:
<img src="%5C%22produkter_org/man/produkter_man_level1.jpg%5C%22" width="150" height="140">
So that dident work so well at all :p
Then im stuck again, so anyone out there with an idea? :)
Kris
opifex
11-29-2009, 05:32 AM
I must be missing something in this thread.... where are these characters coming from to start with??? I didn't see that addressed in the posts (or I missed it somehow).
I would eliminate the "problem at it's source instead of trying to fix it after the fact... just a thought.
norNerd
11-29-2009, 06:01 AM
I cant post my whole code here, as its not small or understandable at all, but ill give you the important things:
<form name="my_form" method="get" action="">
<textarea name="content1" id="content1">
This is the textarea with a name
</textarea>
<textarea name="content2" id="content2">
This is the textarea with a WYSIWYG editor attached. and it contains a image, with html code no [img] or anything
</textarea>
<textarea name="content3" id="content3">
This is also a textarea like the other one content2
</textarea>
<textarea name="content4" id="content4">
This is just like content1 only with a bit more text
</textarea>
</form>
So the thing is that i have to update the content of either content2 or content3 without tuching the rest on a refresh.
I solved that by echoing the content after i sent it to URL, but that gave me the issue i need help with, like sending html thru url and decodeing it
to be "showable".
need some more description?
Kris
opifex
11-29-2009, 07:20 AM
Are you using a standard pre-written WYSIWYG editor? which one?
or one that you put together?
The editor is adding the characters - why? We can only find out seeing that part of the editor... if it is one that everybody has access to it's easy enough to check. If it's not the editor, then it's in the file that you are using to process the output of the editor....