yoshida Posted June 25, 2006 Share Posted June 25, 2006 Yo.I'm trying to make a php script echo html code containing a javascript.The html code looks like this: <html><head><link rel=stylesheet type="text/css" href=apb.css></head><body><div id=menu> <div id=r1></div><div id=r2></div><div id=r3></div><div id=r4></div><div id=r5></div><div id=r6></div> <div id=inhoud> <table cellspacing=5 cellpadding=0 align=center> <tr><td><img src=apblogo.png></tr> <tr><td><a href=nieuws.html target=main onFocus="if(this.blur)this.blur()" onmouseover="document.images['nie'].src='nieover.gif'" onmouseout="document.images['nie'].src='nieout.gif'"><img src=nieout.gif border=none name=nie></a></tr> <tr><td><a href=http://apb.write2me.nl/ target=main onFocus="if(this.blur)this.blur()" onmouseover="document.images['gas'].src='gasover.gif'" onmouseout="document.images['gas'].src='gasout.gif'"><img src=gasout.gif border=none name=gas></a></tr> <tr><td><a href=engeland.html target=main onFocus="if(this.blur)this.blur()" onmouseover="document.images['eng'].src='engover.gif'" onmouseout="document.images['eng'].src='engout.gif'"><img src=engout.gif border=none name=eng></a></tr> </table> </div> <div id=r6></div><div id=r5></div><div id=r4></div><div id=r3></div><div id=r2></div><div id=r1></div></div></body></html> Here's the php script. It's supposed to first echo a form in which I insert the html code, and after you click 'submit' echo the html code. I'll make it add the code to a database later. <html><head><link rel=stylesheet type=\"text/css\" href=apb.css></head><body><div id=menu> <div id=r1></div><div id=r2></div><div id=r3></div><div id=r4></div><div id=r5></div><div id=r6></div> <div id=inhoud> <table cellspacing=5 cellpadding=0 align=center> <tr><td><img src=apblogo.png></tr> <tr><td><a href=nieuws.html target=main onFocus=\"if(this.blur)this.blur()\" onmouseover=\"document.images[\'nie\'].src=\'nieover.gif\'\" onmouseout=\"document.images[\'nie\'].src=\'nieout.gif\'\"><img src=nieout.gif border=none name=nie></a></tr> <tr><td><a href=http://apb.write2me.nl/ target=main onFocus=\"if(this.blur)this.blur()\" onmouseover=\"document.images[\'gas\'].src=\'gasover.gif\'\" onmouseout=\"document.images[\'gas\'].src=\'gasout.gif\'\"><img src=gasout.gif border=none name=gas></a></tr> <tr><td><a href=engeland.html target=main onFocus=\"if(this.blur)this.blur()\" onmouseover=\"document.images[\'eng\'].src=\'engover.gif\'\" onmouseout=\"document.images[\'eng\'].src=\'engout.gif\'\"><img src=engout.gif border=none name=eng></a></tr> </table> </div> <div id=r6></div><div id=r5></div><div id=r4></div><div id=r3></div><div id=r2></div><div id=r1></div></div></body></html> [updated]The javascript seems to need those quotation marks, yet the php script needs to ignore them. Is there an easy sollution for this? Help appreciated.[/updated] Link to comment Share on other sites More sharing options...
skym Posted June 25, 2006 Share Posted June 25, 2006 If I understood corectly your script, then the fastest solution is echo stripslashes($inhoud); A little more complicated solution would be to use if ( get_magic_quotes_gpc() ) { function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : (isset($value) ? stripslashes($value) : null); return $value; } $_POST = stripslashes_deep($_POST); $_GET = stripslashes_deep($_GET); $_COOKIE = stripslashes_deep($_COOKIE);} before using any $_GET, $_POST or $_COOKIE variables.Or putphp_flag magic_quotes_gpc offin the .htaccess file if you use Apache.More: http://www.php.net/manual/en/security.magicquotes.php Link to comment Share on other sites More sharing options...
yoshida Posted June 25, 2006 Author Share Posted June 25, 2006 Stripslashes works! :)Thank you very much <?$pageid=$_GET['pageid'];if ($pageid == insert) { if (isset($_POST['voegtoe'])) { $name=$_POST['name']; $inhoud=$_POST['inhoud']; echo stripslashes($inhoud); } else { echo "<form action=index.php?pageid=insert method=post>"; echo "<b>Naam</b><br><input type=text name=name><br><b>Inhoud</b><br><textarea name=inhoud cols=150 rows=20 WRAP=OFF></textarea>"; echo "<br><br><input type=submit name=voegtoe value=OK>"; }}?> The start of a very dynamic one-script website... kudos to Skym for making this rule so much Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now