Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Encoding HTML to transmit via URL 1

Status
Not open for further replies.

Tama

MIS
Jun 6, 2001
121
0
0
NZ
Hey there

I'm wanting to send small segments of HTML to other webpages (in my case IFRAMEs.) Along these lines:
Code:
[URL unfurl="true"]http://www.mysite.com/newpage.php?content=HTMLHERE[/URL]

I've been using base64_encode / base64_decode but guessing that this is CPU intensive. Is there any other ways I can encode/decode the content so it can still be transmitted through the URL, but is less CPU intensive?

Cheers
Tama

I do my sums on fingers and thumbs.
 
What's wrong if you send small segments of HTML via HTTP (why via URL?!) without any encoding, as text/html?..
 
What I'm trying to do is generate banners (which rotate) and put them in IFRAMEs (so people on slow connections have their content load first.)

The first thing I tried to do was run the IFRAME as a seperate piece of PHP code with a MySQL connection but that rapidly overloaded the DB and CPU as it meant each page had about 4 different DB connections.

So then I switched to generating the dynamic banners from the main page and then passing that info to a seperate page via a Base64 decode.

Example
HTML code on page
Code:
<iframe src="banners-disp.php?c=PGltZyB3aWR0aD0iMSIgaGVpZ2h0PSIxMCIgYm9yZGVyPSIwIiBzcmM9ImltYWdlcy9waXguZ2lmIj48Y2VudGVyPjxhIGhyZWY9ImJhbm5lcnMyLnBocD9vcD1jbGljayZiaWQ9MjMiIHRhcmdldD0iX2JsYW5rIj48Zm9udCBjb2xvcj0iI0ZGRkZGRiIgc2l6ZT0iKzEiPjxiPktlZXdlZSBCaWtlczwvYj48L2ZvbnQ+PC9hPjwvY2VudGVyPjxicj48YnI+PGNlbnRlcj48YSBocmVmPSJiYW5uZXJzMi5waHA/b3A9Y2xpY2smYmlkPTI3IiB0YXJnZXQ9Il9ibGFuayI+PGZvbnQgY29sb3I9IiNGRkZGRkYiIHNpemU9IisxIj48Yj5OWiBNVEIgR3VpZGUgQ0Q8L2I+PC9mb250PjwvYT48L2NlbnRlcj48YnI+PGJyPjxjZW50ZXI+PGEgaHJlZj0iYmFubmVyczIucGhwP29wPWNsaWNrJmJpZD00IiB0YXJnZXQ9Il9ibGFuayI+PGZvbnQgY29sb3I9IiNGRkZGRkYiIHNpemU9IisxIj48Yj5Hcm91bmQgRWZmZWN0IDA0IENsb3RoaW5nPC9iPjwvZm9udD48L2E+PC9jZW50ZXI+PGJyPjxicj4=" width=150 height=250 scrolling="no" frameborder="0" marginwidth="0" marginheight="0"></iframe>

banners-disp.php
Code:
<html>
<head>
<meta http-equiv="Pragma" content="no-cache">
<style>
body	{font-family: Tahoma, Verdana, Arial, Helvetica;}
a 		{ text-decoration: none;}
a:hover { text-decoration: underline;}
</style>
</head>
<body bgcolor="#000000" marginwidth="0" marginheight="0" leftmargin="0" topmargin="0">
<center>
<?php
$c=base64_decode($c);
echo "$c";
?>
</center>
</body>
</html>

I do my sums on fingers and thumbs.
 
Break your lines up man !!!!
I'd use post rather than get (which you are with a query strig in the URL.
look at htmlspecialchars() function
 
Tama:
I must keep in mind that GET-method input has limits to the amount of data that can be transmitted. This limit varies from OS to OS and web serve to web server, but you can only count on having 128 bytes available to you.

If you must use GET, I recommend that you pass only that information necessary for another script to reproduce the page.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Damn, I realized my mistake about two seconds after posting the code. Whoops, sorry. [blush]

I've found what (I think) I'm after - urldecode/ urlencode. I can't believe I missed these before. In the long run I need to look at a more efficient way of doing this.

Cheers
Tama





I do my sums on fingers and thumbs.
 
Thank you Sleipnir - your post made me step back and have a think about how to do this in a way that doesn't suck.

I think I've worked out a way to transmit minimal data via GET, use bugger all CPU, and make one MySQL connection per page.

Will let you know how I go.

Tama

I do my sums on fingers and thumbs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top