Welcome Guest, Not a member yet? Register   Sign In
editing YouTube embed link displays video on page via populating the input field- how do I prevent this?
#1

[eluser]new_igniter[/eluser]
I am allowing users to paste in YouTube embed links, into a database, and allowing them to edit them, if need be.

The problem I am running into is when I populate the edit screen's embed input field, the page reads the html
Code:
<object embed...
and displays the video, and breaks the page.

I have to populate the field, becuase if someone wants to change a title and not the embed link, they will then submit a blank field. And I have to give them the option to edit the embed.

Is there a way I can say, dont render this? But keep in mind, its populating an html input value, so <pre&gt; is not an option as it will get re-submitted with the emed link and then break the video file.

Thanks!
Peter
#2

[eluser]David Rothera[/eluser]
Could you convert it all to html_entities before echoing it to the input form and then convert it back when you write it to the database?

EDIT: Kinda like this (very quick, dont judge Tongue)

Code:
&lt;?php
$haha = '&lt;object width="425" height="355"&gt;<param name="movie" value="http://www.youtube.com/v/Yz1-cPx0cIk&rel=1"></param><param name="wmode" value="transparent"></param>&lt;embed src="http://www.youtube.com/v/Yz1-cPx0cIk&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"&gt;&lt;/embed&gt;&lt;/object&gt;';

$lala = htmlentities($haha);
?&gt;
&lt;form action="blah.php" method="post" accept-charset="utf-8"&gt;
    &lt;input type="text" name="lala" value="&lt;?=$lala;?&gt;" id="lala"&gt;

    <p>&lt;input type="submit" value="Continue &rarr;"&gt;</p>
&lt;/form&gt;

&lt;?php
$hmmm = html_entity_decode($lala);
echo $hmmm;
?&gt;
#3

[eluser]new_igniter[/eluser]
seems like a good approach. I will give it a try
#4

[eluser]new_igniter[/eluser]
worked great! Thanks David.
#5

[eluser]ejangi[/eluser]
Just in case it's useful - we did something with youtube URL's in this post recently as well.
#6

[eluser]codex[/eluser]
[quote author="David Rothera" date="1200630016"]Could you convert it all to html_entities before echoing it to the input form and then convert it back when you write it to the database?

EDIT: Kinda like this (very quick, dont judge Tongue)

Code:
&lt;?php
$haha = '&lt;object width="425" height="355"&gt;<param name="movie" value="http://www.youtube.com/v/Yz1-cPx0cIk&rel=1"></param><param name="wmode" value="transparent"></param>&lt;embed src="http://www.youtube.com/v/Yz1-cPx0cIk&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"&gt;&lt;/embed&gt;&lt;/object&gt;';

$lala = htmlentities($haha);
?&gt;
&lt;form action="blah.php" method="post" accept-charset="utf-8"&gt;
    &lt;input type="text" name="lala" value="&lt;?=$lala;?&gt;" id="lala"&gt;

    <p>&lt;input type="submit" value="Continue &rarr;"&gt;</p>
&lt;/form&gt;

&lt;?php
$hmmm = html_entity_decode($lala);
echo $hmmm;
?&gt;
[/quote]

Super! I was just about to ask the same!




Theme © iAndrew 2016 - Forum software by © MyBB