I want to be able to dynamically insert an HTML tag, by first copying it to a textarea and then submitting it.
This is my first attempt.
<!DOCTYPE html>
<html>
<head>
<title>Tag Parser</title>
</head>
<body>
<form name="tagInput" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
Input Tags:<br>
<textarea name="tag" id="tag">
</textarea>
<br><br>
<input type="submit" name="send" id="send" value="Submit">
</form>
<?php
foreach ($_POST as $key => $value) {
$value = str_replace('"', "'", $value);
echo "field " . $key . " " . "value " . htmlentities($value) . "<br>";
echo "$value";
}
?>
</body>
</html>
When I output the tag with htmlentities(), I see it is formated properly and just like I'd like it to show, but rendered. But then, the second echo is adding the tag, but broken.
This was my input:
<IFRAME SRC="http://ad.doubleclick.net/adi/N7480.147698OMGBLOG1/B8174590.109702939;sz=300x250;ord=[timestamp]?" WIDTH=300 HEIGHT=250 MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR='#000000'> <SCRIPT language='JavaScript1.1' SRC="http://ad.doubleclick.net/adj/N7480.147698OMGBLOG1/B8174590.109702939;abr=!ie;sz=300x250;ord=[timestamp]?"> </SCRIPT> <NOSCRIPT> <A HREF="http://ad.doubleclick.net/jump/N7480.147698OMGBLOG1/B8174590.109702939;abr=!ie4;abr=!ie5;sz=300x250;ord=[timestamp]?"> <IMG SRC="http://ad.doubleclick.net/ad/N7480.147698OMGBLOG1/B8174590.109702939;abr=!ie4;abr=!ie5;sz=300x250;ord=[timestamp]?" BORDER=0 WIDTH=300 HEIGHT=250 ALT="Advertisement"></A> </NOSCRIPT> </IFRAME>
This is what's being generated in the site:
<iframe src="" width="300" height="250" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" bordercolor="#000000"> <SCRIPT language='JavaScript1.1' SRC='http://ad.doubleclick.net/adj/N7480.147698OMGBLOG1/B8174590.109702939;abr=!ie;sz=300x250;ord=[timestamp]?'> </SCRIPT> <NOSCRIPT> <A HREF='http://ad.doubleclick.net/jump/N7480.147698OMGBLOG1/B8174590.109702939;abr=!ie4;abr=!ie5;sz=300x250;ord=[timestamp]?'> <IMG SRC='http://ad.doubleclick.net/ad/N7480.147698OMGBLOG1/B8174590.109702939;abr=!ie4;abr=!ie5;sz=300x250;ord=[timestamp]?' BORDER=0 WIDTH=300 HEIGHT=250 ALT='Advertisement'></A> </NOSCRIPT> </iframe>
The src= is empty and the tag is clearly broken (not rendering anything)